akhauriyash/Code-Regression huggingface dataset:
// finish date: 2019/2/24

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


vb used;
vector<set<int>> edge;
vector<pii> cnt;

pii dfs(int node) {
    if (used[node]) return cnt[node];
    used[node] = true;
    int w = 1, b = 1;
    for (int e:edge[node]) {
        if (!used[e]) {
            pii p = dfs(e);
            w = mul(w, add(p.first, p.second));
            b = mul(b, p.first);
        }
    }
    return pii(w, b);
}

int main() {
    int N;
    cin >> N;
    used = vb(N, false);
    edge = vector<set<int>>(N);
    cnt = vector<pii>(N);
    rep(i, N - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].insert(y);
        edge[y].insert(x);
    }
    pii p = dfs(0);
    cout << add(p.first, p.second) << endl;

    return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (A[i] == A[j] || A[j] == A[k]) continue;
                if (abs(A[i] - A[j]) < A[k] && A[k] < A[i] + A[j]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define maxn 200100

using namespace std;

int n,m,in[maxn],num[maxn][3],col[maxn];
string s;
vector<int> g[maxn],dead;

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    cin>>s;
    for (int i=0;i<n;i++) col[i]=(s[i]=='A');
    for (int i=1,u,v;i<=m;i++) {
        cin>>u>>v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
        num[u][col[v]]++;
        num[v][col[u]]++;
    }
    for (int i=0;i<n;i++)
        if (num[i][0]==0 || num[i][1]==0) {
            dead.push_back(i);
            in[i]=1;
        }
    for (int i=0;i<dead.size();i++) {
        int u = dead[i];
        for (auto v : g[u]) {
            if (in[v]) continue;
            num[v][col[u]]--;
            if (num[v][0]==0 || num[v][1]==0) {
                dead.push_back(v);
                in[v]=1;
            }
        }
    }
    if (dead.size()==n) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 15436
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b; cin >> a >> b;
	if (a <= b)cout << a << "\n";
	else cout << a - 1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    ll n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    
    ll max = a[0];
    ll total = 0;
    
    rep(i,n){
        if(max < a[i]){
            max = a[i];
        }else{
            total += max - a[i];
        }
    }
    cout << total << ln;
    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> a(N);
	for(int i=0; i<N; ++i){
	    int p;
	    cin >> p;
	    a[i]=make_pair(p, i+1);
	}
	sort(a.begin(), a.end());
	cout << a[0].second;
	for(int i=1; i<N; ++i) cout << ' ' << a[i].second;
	cout << endl;
	return 0;
}


Measured memory_bytes: 1664
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n ;
int main ( ){
  int a , b , c;

  cin >> a >> b >> c ;
  for ( int i = min ( a,b) ; i >= 1 ; --i ){
    if ( a%i ==0 && b%i ==0 ){
        c-- ;
        if ( !c ){
            cout << i <<endl;
            return 0;
        }
    }
  }
return 0 ;
}


Measured memory_bytes: 256
#import<cstdio>
int main(){int i,j,n=1<<18;char p[1<<18];for(i=0;i<n;i++)p[i]=(i<2)?0:1;for(i=2;i*i<n;i++)for(j=i*2;j<n;j+=i)p[i]?p[j]=0:0;for(;j=0,scanf("%d",&n),n;printf("%d\n",j))for(i=n+1;i<=2*n;i++)p[i]?j++:0;}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n,m,p;
  while(cin>>n>>m>>p,n||m||p){
    vector<int> x;
    int sum=0;
    for(int i=0,xi;i<n;++i){
      cin>>xi;
      x.push_back(xi);
      sum+=xi;
    }
    cout<<((x[m-1])?sum*(100-p)/x[m-1]:0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstring>
int n,m,x,y,h[100005],ans;
bool b[100005];
int main()
{
	memset(b,true,sizeof b);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&h[i]);
	for(int i=1;i<=m;++i)
	  {
	  	scanf("%d%d",&x,&y);
	  	if(h[x]>h[y])b[y]=false;
	  	else if(h[x]<h[y])b[x]=false;
	  	else b[x]=b[y]=false;
	  }
	for(int i=1;i<=n;++i)if(b[i])++ans;
	printf("%d",ans);
}

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


namespace ABC121A
{
    class MainClass
    {
        static int[] s;
        static int[] n;
        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            Console.WriteLine((s[0] - n[0]) * (s[1] - n[1]));


        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans;
vector<ll>v;
int32_t main(){
cin>>n;
for(ll i=1;i<=n;i++)
{
v.clear();
ll x=i;
x=i;
while(x){
v.pb(x%10);
x=x/10;
}
if(v.size()%2==1){
ans++;
}
}
cout<<ans<<endl;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, n, a) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  map<string, bool> mp;
  string s[100001];
  rep(i, 0, n) cin >> s[i];
  mp[s[0]] = true;
  rep(i, 1, n) {
    if(mp[s[i]]) {
      cout << "No" << endl;
      return 0;
    }
    mp[s[i]] = true;
    if(s[i][0] != s[i - 1][s[i - 1].length() - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }
    else if(a >= 6){
        cout << b / 2 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a , b, c;
    cin >> a >> b >> c;
    if(a + b == c || b + c == a || c + a == b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
for i in range(1, 100):
    W = int(input())
    if not W:
        break
    N = int(input())
    data = [tuple(map(int, input().split(','))) for _ in range(N)]
    dp = [[[0, 0] for j in range(W + 1)] for i in range(N + 1)]
    print('Case {0}:'.format(i))
    for i in range(1, N + 1):
        for j in range(W + 1):
            if data[i - 1][1] <= j:
                pt = dp[i - 1][j - data[i - 1][1]][:]
                for k in range(2):
                    pt[k] += data[i - 1][k]
                dpt = dp[i - 1][j][:]
                if pt[0] > dpt[0]:
                    dp[i][j] = pt
                elif dpt[0] > pt[0]:
                    dp[i][j] = dpt
                else:
                    dp[i][j] = pt if pt[1] < dpt[1] else dpt
            else:
                dp[i][j] = dp[i - 1][j]
    for i in range(2):
        print(dp[N][W][i])

Measured memory_bytes: 116552
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe";
	else cout << "safe";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) c.begin(),c.end()
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
#define sizestr(i,x)  size_t i=x.length();
using namespace std;



int main(){
int n,k;cin>>n>>k;
vi a(n);
rep(j,n)cin>>a.at(j);
int flag=0;
rep(i,k){
    vi sum(n+2);
    rep(j,n){
        int b=j+1-a.at(j);
        if(b<=0)b=1;
        int c=j+1+a.at(j);
        if(c>n)c=n;
        sum.at(b)+=1;
        sum.at(c+1)-=1;
    }
    for(int h=1;h<=n;h++){
       if(h==1){
            a.at(h-1)=sum.at(h);
           continue;
       }
        sum.at(h)+=sum.at(h-1);
        a.at(h-1)=sum.at(h);
    }

/*rep(hu,n){
    a.at(hu)=sum.at(hu+1);
}*/
rep(h,n){
    if(a.at(h)==n){
        if(h==n-1){
            flag++;
            break;
        }
        continue;
    }
    break;
}
if(flag)break;
}



rep(g,n){
cout<<a.at(g)<<" ";
}
cout<<endl;
}


Measured memory_bytes: 4800
//#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 1001
#define INF (int)1e9
#define mod 1000000007LL
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

ll Qpow(ll x,ll k){
	if (k<=0){
		return 1LL;
	}
	ll ans=1LL;
	while (k){
		if (k&1LL){
			ans=(ans*x)%mod;
		}
		x=(x*x)%mod;
		k/=2;
	}
	return ans;
}


int mp[inf][inf],tmp[inf][inf];

struct matrix{
	int n,m;
	ll mat[5][5];
	matrix(){
		memset(mat,0,sizeof(mat));
	}
	matrix(int nn,int mm){
		memset(mat,0,sizeof(mat));
		n=nn,m=mm;
	}
};

matrix multiply(matrix a,matrix b){
	matrix ans=matrix(2,2);
	for (int i=1;i<=2;i++){
		for (int j=1;j<=2;j++){
			for (int k=1;k<=2;k++){
				ans.mat[i][j]=(ans.mat[i][j]+a.mat[i][k]*b.mat[k][j]%mod)%mod;
			}
		}
	}
	return ans;
}

matrix mat_pow(matrix a,ll k){
	matrix ans=matrix(2,2);
	ans.mat[1][1]=ans.mat[2][2]=1LL;
	if (k<=0){
		return ans;
	}
	while (k){
		if (k&1LL){
			ans=multiply(ans,a);
		}
		a=multiply(a,a);
		k/=2LL;
	}
	return ans;
}

int n,m;
ll k;

int cal1(void){
	int ans=0;
	for (int i=1;i<=m;i++){
		if (mp[1][i]==mp[n][i] && mp[1][i]==1){
			ans++;
		}
	}
	return ans;
}

int cal2(void){
	int ans=0;
	for (int i=1;i<=n;i++){
		if (mp[i][1]==mp[i][m] && mp[i][1]==1){
			ans++;
		}
	}
	return ans;
}

int main(){
	rd(n) rd(m) rd(k)
	char c;
	int sum1=0LL,sum2=0LL;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			c=getchar();
			while (c!='.' && c!='#'){
				c=getchar();
			}
			if (c=='#'){
				mp[i][j]=1;
				sum1++;
			}
		}
	}
	int cnt1=cal1(),cnt2=cal2();
	if (cnt1 && cnt2){
		puts("1");
		return 0;
	}
	if (!cnt1 && !cnt2){
		printf("%lld\n",Qpow(sum1,k-1LL));
		return 0;
	}
	if (cnt2){
		cnt1=cnt2;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++){
				tmp[m-j+1][i]=mp[i][j];
			}
		}
		swap(n,m);
		memcpy(mp,tmp,sizeof(tmp));
	}
	for (int i=1;i<n;i++){
		for (int j=1;j<=m;j++){
			sum2+=(mp[i][j] && mp[i+1][j]);
		}
	}
	matrix a;
	a.n=a.m=2;
	a.mat[1][1]=(ll)sum1,a.mat[1][2]=(ll)sum2,a.mat[2][2]=(ll)cnt1;
	a=mat_pow(a,k-1);
	printf("%lld\n",(a.mat[1][1]-a.mat[1][2]+mod)%mod);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int>cnt[26];
signed main() {
    string S,T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++) {
        cnt[S[i]-'a'].push_back(i);
    }
    for(int i = 0; i < T.size(); i++) {
        if(cnt[T[i]-'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    int now = -1;
    int res = 0;
    for(int i = 0; i < T.size(); i++) {
        int l = -1,r = cnt[T[i]-'a'].size();
        while(l+1 < r) {
            int mid = (l+r)/2;
            if(cnt[T[i]-'a'][mid] > now) {
                r = mid;
            }
            else {
                l = mid;
            }
        }
        if(r == cnt[T[i]-'a'].size()) {
            now = cnt[T[i]-'a'][0];
            res++;
        }
        else {
            now = cnt[T[i]-'a'][r];
        }
    }
    cout << now+res*S.size()+1 << endl;
}


Measured memory_bytes: 4660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int start=-1,end=-1;
    for(int i=0;i<s.length();i++){
        if(s.substr(i,1)=="A"&&start==-1){
            start=i;
        }
        if(s.substr(i,1)=="Z"){
            end=i;
        }
    }
    cout << end-start+1 << endl;
}


Measured memory_bytes: 640
import sys
s = input()
state = False
if s[0] != "A":
    print("WA")
    sys.exit()
cnt = 0
for i in range(2,len(s)-1):
    if s[i] == "C":
        cnt +=1
if cnt != 1:
    print("WA")
    sys.exit()
for i in range(len(s)):
    if s[i] == "A":
        continue
    elif s[i] == "C":
        continue
    elif s[i].islower():
        continue
    else:
        print("WA")
        sys.exit()
print("AC")

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

int main() {

  int X, Y, four, two;
  cin >> X >> Y;

  two = 2 * X;
  four = 4 * X;  

  if (Y >= two && Y <= four){
    if (Y % 2 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

}

Measured memory_bytes: 3632
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
B = [abs(a-b) for a,b in zip(A,A[1:])]
C = sum(B)

for n in range(N):
  print(C+abs(A[n]-A[n+2])-(B[n]+B[n+1]))

Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll A,B;
    cin >> A >> B;
    ll ans = 0;
    if(A > B)swap(A,B);
    ans += B;
    B--;
    if(A > B)swap(A,B);
    ans += B;
    B--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<int>>dp(n+1,vector<int>(n+1,0));
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            int l,r;
            if(s[i-2]=='<')
            {
                l=1;r=j-1;
            }
            else {
                l=j;r=i-1;
            }
            // if(l<=r)
            dp[i][j]=(dp[i-1][r]-dp[i-1][l-1]+mod)%mod;
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    long long ans=dp[n][n];
    cout<<ans;
}


Measured memory_bytes: 35584
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    r = 0
    for c in a:
        while c % 2 == 0:
            c //= 2
            r += 1
    return r


print(main())



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

struct S{
  S(){};
  S(int xx,int yy){
    x=xx;
    y=yy;
  }
  int x,y;
};
bool operator<(S a,S b){
  int aa = a.x*a.x+a.y*a.y;
  int bb = b.x*b.x+b.y*b.y;
  if(aa!=bb){
    return aa<bb;
  }else{
    return a.x<b.x;
  }
}
int x,y;
S a;
bool input(){
  a = S(150,150);
  cin>>x>>y;
  if(y==0&&x==0){
    return false;
  }else{
    return true;
  }
}

void solve(){
  S in(x,y);
  for(int i=1;i<150;i++){
    for(int j=i+1;j<150;j++){
      S comp(i,j);
      if(in<comp&&comp<a){
        a=comp;
      }
    }
  }
}

int main(){
  while(input()){
    solve();
    cout<<a.x<<" "<<a.y<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
map<string,int> cnt;
int maxi=0;
vector<string> sol;

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

	cin>>n;
	string s;
	for(int i=0;i<n;i++)
    {
        cin>>s;
        cnt[s]++;
        maxi=max(maxi,cnt[s]);

    }
    map<string,int>::iterator it=cnt.begin();
    while(it!=cnt.end())
    {
        if(it->second==maxi)
            sol.push_back(it->first);

        it++;
    }
    sort(sol.begin(),sol.end());
    for(int i=0;i<sol.size();i++)
        cout<<sol[i]<<endl;

	return 0;
}


Measured memory_bytes: 25584
#include<iostream>
#include<cstring>

using namespace std;

int n,w;
int v[100][2];
int dp[10001];

int dfs(int k){
  for(int i = w; i >= 0; i--){
    if(dp[i] != -1){
      if(i + v[k][1] <= w)dp[i + v[k][1]] = max(dp[i + v[k][1]], dp[i] + v[k][0]);
    }
  }
  if(k < n-1) return dfs(k+1);
  else return 0;
}

int main(){
  cin >> n >> w;
  for(int i = 0; i < n ;i++){
    cin >> v[i][0] >> v[i][1];
  }
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  dfs(0);
  int m = 0;
  for(int i = 0; i <= w; i++){
    m = max(m, dp[i]);
  }
  cout << m << endl;
}



Measured memory_bytes: 3128
#include <iostream>

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;

int main () {
    string s;
    cin >> s;
    rep(i, s.length()){
        if ((i+1)%2 == 0) {
            if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
if(x%y==0)std::cout << 0 << '\n';
else std::cout << 1 << '\n';
}


Measured memory_bytes: 256
import math

Q = int(input())

D = []
for i in range(Q):
  D.append(list(map(int, input().split())))
           
for i in D:
  t = i[0] * i[1]
  l = int(t**0.5)
  if i[0] == i[1]:
    Ans = (l - 1) * 2
  elif l * l == t:
    Ans = (l - 1) * 2 - 1
  elif l * (l + 1) >= t:
    Ans = (l - 1) * 2
  else:
    Ans = l * 2 - 1
  print(Ans)
  

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    int ans = 0;
    for(int i=0; i<N; i++)
        if(h[i]>=K) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100010],b[100010],c[100010];
int f[100010][5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	f[1][1]=a[1];
	f[1][2]=b[1];
	f[1][3]=c[1];
	for(int i=2;i<=n;i++)
	{
		f[i][1]=a[i]+max(f[i-1][2],f[i-1][3]);
		f[i][2]=b[i]+max(f[i-1][1],f[i-1][3]);
		f[i][3]=c[i]+max(f[i-1][1],f[i-1][2]);
	}
	printf("%d",max(f[n][1],max(f[n][2],f[n][3])));
	return 0;
}

Measured memory_bytes: 3328
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<vector<char>> M(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> M[i][j];
    }
  }

  queue<pair<int, pair<int, int>>> que;
  vector<pair<int, int>> dir(4);
  dir[0] = {+1, 0};
  dir[1] = {-1, 0};
  dir[2] = {0, +1};
  dir[3] = {0, -1};
  int ans = 0;
  rep(i, H) {
    rep(j, W) {
      if (M[i][j] == '#') continue;
      int step = 0;
      que.push({0, {i, j}});
      vector<vector<bool>> visit(H, vector<bool>(W, false));
      visit[i][j] = true;
      while (!que.empty()) {
        auto t = que.front();
        que.pop();
        step = max(step, t.first);
        for (auto d : dir) {
          int ny = t.second.first + d.first;
          int nx = t.second.second + d.second;
          if (nx < 0 || ny < 0 || H <= ny || W <= nx) continue;
          if (M[ny][nx] == '#') continue;
          if (visit[ny][nx] == true) continue;
          visit[ny][nx] = true;
          que.push({t.first + 1, {ny, nx}});
        }
      }
      ans = max(ans, step);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var (n,x,t) = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()

    var ans = 0
    var c = 0
    while(ans<n)
    {
        ans+=x
        c+=t
    }
    println(c)
}


Measured memory_bytes: 38312
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  for (int i = k; i < n; ++i) {
    if (a[i-k] < a[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

int main() {
  int H,W,x;
  cin >> H >> W;
  string S,t,u;
  for (int i = 0; i < H; i++) {
    cin >> S;
    t += S;
  }
  for (int j = 0; j < t.size(); j++) {
    x = 0;
    if (t.at(j) == '.') {
         if (j >= W) {
          if (j > W) {
            if (t.at(j-W-1) == '#' && j % W != 0 && (j-W-1) >= 0) {
            x++;
            }
          }
          if (t.at(j-W) == '#') {
            x++;
          }
          if (t.at(j-W+1) == '#' && (j+1) % W != 0) {
            x++;
          }
        }
      if (j < (t.size() -W)) {
        if (t.at(j+W-1) == '#' && j % W != 0) {
          x++;
        }
        if (t.at(j+W) == '#') {
          x++;
        }
        if (j < (t.size() -W -1)) {
          if (t.at(j+W+1) == '#' && (j+1) % W != 0) {
          x++;
          }
        }
      }
        if (j > 0) {
          if (t.at(j-1) == '#' && j % W != 0) {
            x++;
          }
        }
        if (j < (t.size() -1)) {
          if (t.at(j+1) == '#' && (j+1) % W != 0) {
            x++;
          }
        }
      if (x == 1) {t.at(j) = '1';
      } else if (x == 2) {t.at(j) = '2';
      } else if (x == 3) {t.at(j) = '3';
      } else if (x == 4) {t.at(j) = '4';
      } else if (x == 5) {t.at(j) = '5';
      } else if (x == 6) {t.at(j) = '6';
      } else if (x == 7) {t.at(j) = '7';
      } else if (x == 8) {t.at(j) = '8';
      } else {t.at(j) = '0';
      }
    }
  }
  for (int k = 0; k < t.size(); k++) {
    if ((k+1) % W == 0) {
      u += t.at(k);
      u += '\n';
    } else {
      u += t.at(k);
    }
  }
  cout << u << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int ans1[100010],ans2[100010],a[100010],last=0;
char b[100010];
    
int main()
{   scanf("%s",&b);
    int n=strlen(b);
	for(int i=0;i<n;++i)
		if(b[i]=='R')
		    ans1[i]=ans1[i-1]+1;
		else
		    ans1[i]=0;
	for(int i=n-1;i>=0;--i)
		if(b[i]=='L')
		    ans2[i]=ans2[i+1]+1;
		else
		    ans2[i]=0;
    for(int i=1;i<n;++i)
    {
    	if(b[i-1]=='R' && b[i]=='L')
    	{
    		int t=max(ans1[i-1],ans2[i])-1,x=0,y=0;
    		x=(ans1[i-1]+1)/2+(ans2[i]/2);
    		y=(ans2[i]+1)/2+(ans1[i-1]/2);
    		if(t%2==0) 
    		    a[i-1]=x,a[i]=y;
    		else 
    		{
    		    if(ans1[i-1]>ans2[i] && x<y)
					    swap(x,y);
				else if(ans1[i-1]<ans2[i] && x>y)
    		            swap(x,y);
				a[i-1]=y,a[i]=x;
    		}
    		i=i+ans2[i]-1;
		}
	}
	for(int i=0;i<n;++i)
	    cout<<a[i]<<' ';
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{cout<<#r": ";for(const auto &i:r){cout<<i<<" ";}cout<<endl;}while(0)
int main()
{
    int N; cin >> N;
    vector<Int> A(N+1);
    FOR(i, 1, N+1) {
        cin >> A[i];
        A[i] += A[i-1];
    }
    Int mindiff = numeric_limits<Int>::max();
    for (int i = 1; i <= N-1; i++) {
        Int x = A[i];
        Int y = A[N] - x;
        Int diff = abs(x - y);
        mindiff = min(mindiff, diff);
    }
    cout << mindiff << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long a, b, c; cin >> a >> b >> c;
	long long d = c - a - b;
	if (d > 0 && 4 * a*b < d*d)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
m = 0
list = []
ans = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

while True:
    n,x = map(int,input().split())

    if n==0 and x==0:
        break

    else:
        for i in range(1,n+1):
            m = 0
            for j in range(i+1,n+1):
                if not i == j:
                    m = i + j
                    for k in range(j+1,n+1):
                        if not i == k:
                            if not j ==k:
                                if k == x-m:
                                    list.append(sorted([i,j,k]))
        ans.append(len((get_unique_list(list))))
        list =[]

[print(i) for i in ans]


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int a[3];
int main(){

    rep(i,3){
      cin>>a[i];
    }
    sort(a,a+3);

    int sa=a[2]-a[0];
    int ans=0;
    if(sa%2==0){
      ans+=sa/2;
      int sa2=a[2]-a[1];

      if(sa2%2==0){
        ans+=sa2/2;
      }else{
        ans+=sa2/2;
        ans+=2;
      }
    }else{
      ans+=sa/2;
      int sa2=a[2]-a[1];

      if(sa2%2==0){
        ans+=sa2/2;
        ans+=2;

      }else{
        ans+=sa2/2;
        ans+=1;
      }
    }

    cout<<ans<<endl;


}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    ll ans = 8e18;
    for (int a = 0; a < N; a++) {
        for (int b = a + 1; b < N; b++) {
            for (int c = 0; c < N; c++) {
                for (int d = c + 1; d < N; d++) {
                    ll mx = min(x[a], x[b]);
                    ll Mx = max(x[a], x[b]);
                    ll my = min(y[c], y[d]);
                    ll My = max(y[c], y[d]);

                    int cnt = 0;
                    for (int i = 0; i < N; i++) {
                        if (mx <= x[i] && x[i] <= Mx && my <= y[i] && y[i] <= My) {
                            cnt++;
                        }
                    }
                    if (cnt >= K) {
                        ans = min(ans, (Mx - mx) * (My - my));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
        k: usize,
        h: [usize; n],
    );

    h.sort();

    let mut ans: usize = std::usize::MAX;
    for i in 0..(n-k+1) {
        ans = std::cmp::min(ans, h[i+k-1] - h[i]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
from itertools import combinations
n = int(input())
a = [int(i) for i in input().split()]
a.sort()

ai = a[-1]
aj = -1
for i in range(n-1):
    if abs(a[i] - ai/2) <= abs(aj - ai/2):
        aj = a[i]
print(ai, aj)

Measured memory_bytes: 14348
#include <bits/stdc++.h>
using namespace std;
#define N 100005
int arr[N][3];
int vaction(int n)
{
    for(int i=1;i<n;i++)
    {
        arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
        arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
        arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
    }
    return max((max(arr[n-1][0],arr[n-1][1])),arr[n-1][2]);
}
 
int main() 
{
int n,a,b,c;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>a>>b>>c;
    arr[i][0]=a;
    arr[i][1]=b;
    arr[i][2]=c;
}
	cout<<vaction(n)<<"\n";
}


Measured memory_bytes: 1536
n, m = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i).sort
distances = []
(0...(m - 1)).each do |i|
  distances << arr[i + 1] - arr[i]
end
distances = distances.sort.reverse
result = (arr.last - arr.first).abs
(0...([n - 1, distances.count].min)).each do |i|
  result -= distances[i]
end
puts result

Measured memory_bytes: 11888
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<ll> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    
    for (ll i = 0; i < arr.size(); i ++)
    {
        if (num % arr[i] == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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


int main(){
    ll a,b;
    cin >> a>>b;
    ll c=gcd(a,b);
    ll ans=1;
    cerr<<1<<endl;
    double d=sqrt(c);
    for(ll i=2;i<=d;i++){
        if(c%i==0){
            while(c%i==0){
                c/=i;
            }
            ans++;
            cerr<<i<<endl;
        }
    }
    if(c!=0&&c!=1){
        ans++;
        cerr<<c<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;


void solve(long long A, long long B, long long K){
    set<long long> num;
    REP(i, K)
        if (A + i <= B)
            num.insert(A + i);
    REP(i, K)
        if (B - i >= A)
            num.insert(B - i);
    for (auto itr = num.begin(); itr != num.end(); itr++)
        cout << *itr << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct Edge{
	long long to,cost,dis;//used in state is cur_v,cur_money,distance with node 1
};
vector<Edge> g[55];
long long c[55],d[55],dp[55][2550],maxv=2500;
struct cmp{
	bool operator()(const Edge a,const Edge b)const{
		return a.dis>b.dis;
	}
};
priority_queue<Edge,vector<Edge>,cmp> pq;
int main(){
	long long i,j,n,m,s,u,v,a,b;
	scanf("%lld%lld%lld",&n,&m,&s);
	for(i=0;i<m;i++){
		scanf("%lld%lld%lld%lld",&u,&v,&a,&b);
		g[u].emplace_back((Edge){v,a,b});
		g[v].emplace_back((Edge){u,a,b});
	}
	for(i=1;i<=n;i++)	
		scanf("%lld%lld",&c[i],&d[i]);
	for(i=0;i<55;i++)
		for(j=0;j<2550;j++)
			dp[i][j]=100000000000000000;
	s=min(s,maxv);
	pq.push({1,s,0});
	dp[1][s]=0;
	while(pq.size()){
		auto x=pq.top();
		pq.pop();
		if(dp[x.to][x.cost]<x.dis)
			continue;
		for(auto y:g[x.to]){
			for(i=0;;i++){
				if(x.cost+i*c[x.to]<y.cost)
					continue;
				if(dp[y.to][min(x.cost+i*c[x.to]-y.cost,maxv)]>dp[x.to][x.cost]+i*d[x.to]+y.dis){
					dp[y.to][min(x.cost+i*c[x.to]-y.cost,maxv)]=dp[x.to][x.cost]+i*d[x.to]+y.dis;
					pq.push({y.to,min(x.cost+i*c[x.to]-y.cost,maxv),dp[y.to][min(x.cost+i*c[x.to]-y.cost,maxv)]});	
				}
				if(x.cost+i*c[x.to]-y.cost>maxv)
						break;
			}
		}
	}
	for(i=2;i<=n;i++)
		printf("%lld\n",*min_element(dp[i],dp[i]+maxv));
}

Measured memory_bytes: 200492
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 200010;

int n, tmp, tp, ans, x;
int na[N], nb[N], a[N];

int find(int l, int r)
{
    return (upper_bound(a + 1, a + n + 1, r) - lower_bound(a + 1, a + n + 1, l)) & 1;
}

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", na + i);
    FOR(i, 1, n) scanf("%d", nb + i);
    FOR(i, 1, 29)
    {
        FOR(j, 1, n) a[j] = na[j] & ((1 << i) - 1);
        sort(a + 1, a + n + 1);
        tmp = 0; tp = 1 << (i - 1);
        FOR(j, 1, n)
        {
            x = nb[j] & ((1 << i) - 1);
            if (x & tp)
            {
                tmp ^= find(0, 2 * tp - x - 1);
                tmp ^= find(3 * tp - x, 2 * tp - 1);
            }
            else tmp ^= find(tp - x, 2 * tp - x - 1);
        }
        if (tmp) ans += tp;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
// AOJ 1089: Strawberry Cake
// 2017.12.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define N 75
#define D 0.05
#define EPS 1e-8

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;

PP a[21]; int n;

int dcmp(double x)
{
	if (fabs(x) < EPS) return 0;
	return x < 0 ? -1 : 1;
}

double cross(double ax, double ay, double bx, double by) { return ax*by - ay*bx; }

void lineIntersection(PP *p, LINE *a, PP *vs, PP *ve)
{
    double a1, a2;

	a1 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->s.x - vs->x, a->s.y - vs->y);
	a2 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->e.x - vs->x, a->e.y - vs->y);
	p->x = (a->s.x*a2 - a->e.x*a1) / (a2-a1);
	p->y = (a->s.y*a2 - a->e.y*a1) / (a2-a1);
}

int convex_cut(LINE *u, int n, PP *p, PP *po)
{
	int i, d1, d2, top = 0;

    for (i = 0; i < n; i++) {
        d1 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
						p[i].x - u->s.x, p[i].y - u->s.y));
        d2 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
				      p[i+1].x - u->s.x, p[i+1].y - u->s.y));
        if (d1 >= 0) po[top++] = p[i];
        if (d1*d2 < 0) lineIntersection(po + top++, u, p+i, p+i+1);
    }
	po[top] = po[0];
#if 0
printf("convex_cut %d\n", top);
for (i = 0; i < top; i++) printf("[%d] (%lf,%lf)\n", i+1, po[i].x, po[i].y);
#endif
	return top;
}

#if 0
double area(int n, PP *p)
{
	int i;
    double s = 0;

    for (i = 1; i < n-1; i++) {
        s += cross(p[i].x-p[0].x, p[i].y-p[0].y, p[i+1].x-p[0].x, p[i+1].y-p[0].y);
    }
    return fabs(s) / 2;
}
#endif

double area(int n, PP *pp)
{
   int i;
   double s;

   for (s = 0, i = 0; i < n; i++) {
      s += (pp[i].x - pp[i+1].x) * (pp[i].y + pp[i+1].y);
   }
   return fabs(s)/2;
}

double calc(double x, double s)
{
	int k;
	PP b[30];

	LINE u;
	u.s.x = u.s.y = 0;
	u.e.x = 128*cos(x), u.e.y = 128*sin(x);
	k = convex_cut(&u, n, a, b);
	return area(k, b) / s;
}

int main()
{
	int i, x, y;
	double s, s1, s2, l, r, m;

	while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			a[i].x = x, a[i].y = y;
		}
		a[n] = a[0];
		s = area(n, a);

		l = 0, r = D, s1 = calc(0, s);
		for ( ; ; l+=D, r+=D, s1 = s2) {
			s2 = calc(r, s);
			if (s1 <= 0.5 && s2 >= 0.5) {
				i = N; while (i--) {
					m = (l+r)/2;
					if (calc(m, s) <= 0.5) l = m; else r = m;
				}
				break;
			}
		}
		printf("%.15lf %.15lf\n", 128*cos(m), 128*sin(m));
	}
	return 0;
}

Measured memory_bytes: 2128
n,k=map(int,input().split())
ans=[0]*n
for i in range(k):
    d=(int(input()))
    a=(list(map(int,input().split())))
    for j in range(len(a)):
        ans[a[j]-1]+=1
res=0
for i in range(n):
    if(ans[i]==0):
        res+=1
print(res)

Measured memory_bytes: 67880
import sys

a,b=map(int, input().split())

abcs = input()
 
def change_upper_to_lower(str, num):
  
  before = str[:int(num) - 1]
  after = str[int(num):]

  if(str[int(num) - 1] == "A"):
    newstr = before + "a" + after
  elif(str[int(num) - 1] == "B"):
    newstr = before + "b" + after
  else:
    newstr = before + "c" + after
    
  return newstr
 
 
changed_abcs = change_upper_to_lower(abcs, b)
 
print(changed_abcs)

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if ((S[0] == 'A') && (S[1] == 'A') && (S[2] == 'A')){
		cout << "No" << endl;
		return 0;
	}
	if ((S[0] == 'B') && (S[1] == 'B') && (S[2] == 'B')){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << "\n";

	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

string lol[] = {"AC", "WA", "TLE", "RE"};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<string, int> c;
    c["AC"] = c["WA"] = c["TLE"] = c["RE"] = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        c[s]++;
    }
    for (int i = 0; i < 4; i++) {
        cout << lol[i] << " x " << c[lol[i]] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3660