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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
ld s[3003][3003],a[3003];

int32_t main()
{
    fast
    int n;  cin>>n;
    f(i,1,n)    cin>>a[i];
    s[1][1]=a[1];
    s[1][0]=1.00-a[1];
    f(i,2,n){
        s[i][0]=s[i-1][0]*(1.00 -a[i]);
        f(j,1,i)
            s[i][j]=s[i-1][j-1]*a[i] + s[i-1][j]*(1.00 -a[i]);
    }
    ld ans=0.00;
    f(i,n/2+1 ,n) ans+=s[n][i];
    cout<<fixed<<sp(10)<<ans;
}

Measured memory_bytes: 85604
N=int(input())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
count=0
for i in range(N):
    if(a[i]==b[i]):
        count=count+1
        if(count==3):
            print('Yes')
            exit()
    else:
        count=0
print('No')


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;
int a[4][MAXN];
int b[MAXN];
int c[MAXN], d[MAXN];

void read(){
	scanf("%d", &n);
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= n; j++)
			scanf("%d", &a[i][j]);
	}	
}

int solve(){
	for(int i = 1; i <= n; i++){
		int p = a[1][i], q = a[2][i], r = a[3][i];
		if (q % 3 != 2) return 0;
		if (p + r != q * 2) return 0;
		if (abs(p - q) != 1 || abs(r - q) != 1) return 0;
		if (p < r)
			b[i] = r / 3;
		else
			b[i] = -p / 3;
	}	
	for(int i = 1; i <= n; i++){
		if (abs(b[i]) % 2 != i % 2)
			return 0;
	}
	for(int i = 1; i <= n; i++){
		c[abs(b[i])] = i;
	}
	for(int i = 1; i <= n; i++){
		int x = c[i];
		if (x != i){
			d[i] = b[x] * ((x - i) % 4 == 0 ? 1 : -1);
			b[i+1] *= -1;
			b[x] = b[i] * ((x - i) % 4 == 0 ? 1 : -1);
			c[abs(b[x])] = x;
		}
		else
			d[i] = b[i];
	}
	for(int i = 1; i <= n - 2; i++){
		if (d[i] < 0){
			d[i + 2] *= -1;
		}
	}
	return d[n-1] > 0 && d[n] > 0;
	/*
	for(int i = 1; i <= n; i++)
		cout<<b[i]<<' '; cout<<endl;
	int p = 0, q = 0;
	for(int i = 1; i <= n; i++){
		if (i & 1){
			if (abs(abs(b[i]) - i) / 2 % 2 != (b[i] < 0))
				p++;
		}
		else{
			if (abs(abs(b[i]) - i) / 2 % 2 != (b[i] < 0))
				q++;
		}
	}
	cout<<p<<' '<<q<<endl;
	return p % 2 == q % 2;*/
}

void printans(int flag){
	puts(flag ? "Yes" : "No");
}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		;
		printans(solve());
	}
	return 0;
} 


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

int main()
{
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k + 1){
    rep(j, k + 1){
      int z = s - i - j;
      if(0 <= z && z <= k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(void){
   
  int K,S,ans=0;
  cin >> K >> S;
  for(int i=0;i<=K;i++){
      for(int j=0;j<=K;j++){
        if(0 <= S-i-j && S-i-j <= K) ans++;
      }
  }
   cout << ans << endl;
}

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

const ll mod = 1e9 + 7;

ll digsum(ll n, ll b) {
  ll sum = 0;
  while (n != 0) {
    sum += n % b;
    n /= b;
  }
  return sum;
}

int main() {
  ll n, s;
  cin >> n >> s;
  ll maxb = sqrt(n);
  ll ans = LLONG_MAX;
  if (s == n) {
    cout << n+1 << endl;
    return 0;
  } else if (s > n) {
    cout << -1 << endl;
    return 0;
  }
  
  for (ll b = 2; b <= maxb; b++) {
    ll c = digsum(n, b);
    if (c == s) {
      ans = b;
      break;
    }
  }
  // n-s = p(b-1)
  ll x = n - s;
  ll p = 1;
  while (p <= maxb) {
    if (x % p == 0) {
      ll b = x/p + 1;
      if (digsum(n, b) == s && b != 1) {
        ans = min(b, ans);
      }
    }
    p++;
  }
  cout << (ans == LLONG_MAX ? -1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 3676
input_s = str(input())
[n, k] = list(map(int, input_s.split(' ')))
m = []
for i in range(0, n):
    tmp = str(input())
    if tmp.find('#') > -1:
        m.append(tmp)
ta = []
for i in range(0, k):
    tmp = ''
    for j in m:
        tmp += j[i]

    ta.append(tmp)
tb = []
for i in ta:
    if i.find('#') > -1:
        tb.append(i)

result = []
for i in range(0, len(tb[0])):
    tmp = ''
    for j in tb:
        tmp += j[i]
    result.append(tmp)

for i in result:
    print(i)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int64_t N, M, count = 0;
	cin >> N >> M;
	if(N == 1){
		if(M == 1){
			count = 1;
		}else if(M >= 3){
			count = M - 2;
		}
	}else if(N >= 3){
		if(M == 1){
			count = N - 2;
		}else if(M >= 3){
			count = (N-2)*(M-2);
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yay!":":(")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    yorn(a <= 8 && b <= 8)
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  int A ,B;
  cin >> A >> B;
  
  if(A%K == 0 || B%K == 0){
    cout << "OK" << endl;
  }
  else if(A/K != B/K ){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  string S;
  while (cin >> S) {
    int N = S.size();
    bool ok = true;
    ok &= S[0] == '1';
    ok &= S[N - 1] == '0';
    for (int i = 0; i < N - 1; i++) {
      ok &= S[i] == S[N - 2 - i];
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    vec<int, 2> G(N);
    int r = 0;
    int v = 1;
    int pre = 1;
    for (int i = 1; i < (N + 1) / 2; i++) {
      if (S[i] == '0') continue;
      G[v].push_back(r);
      r = v;
      ++v;
      int need = (i + 1) - 1 - pre;
      for (int j = 0; j < need; j++) {
        G[r].push_back(v);
        ++v;
      }
      pre = i + 1;
    }
    if (v < N) {
      G[v].push_back(r);
      r = v;
      ++v;
    }
    while (v < N) {
      G[r].push_back(v);
      ++v;
    }
    for (int i = 0; i < N; i++) {
      for (int j : G[i]) {
        cout << (i + 1) << " " << (j + 1) << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 5756
// at_abc147cv2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN = 16;
#define MP make_pair
int main()
{
	int N; cin >> N;
	vector<pair<int, int>>arr[MAXN];
	for (int i = 0;i < N;i++) {
		int temp;cin >> temp;
		for (int a = 0;a < temp;a++) {
			int v1, v2;cin >> v1 >> v2;v1--;
			arr[i].push_back(MP(v1, v2));
		}
	}
	int ans = 0;
	for (int i = 0;i < (1 << N);i++) {
		int Count = 0;
		bool flag = true;
		for (int a = 0;a < N;a++) {
			if (i & (1 << a)) {
				//cout << a << " ";
				//meaning a is honest.
				for (auto x : arr[a]) {
					if (i & (1 << (x.first))) {
						if (!x.second) {
							flag = false;
							break;
						}
					}
					else {
						if (x.second) {
							flag = false;
							break;
						}
					}
				}
				//cout << "\n";
			}
		}
		for (int a = 0; a < N; a++) {
			if (i & (1 << a)) {
				//cout << "1";
			}
			else {
				//cout << "0";
			}
		}
		//cout << "\n"<<flag<<"\n";
		if (!flag)continue;
		for (int a = 0; a < N; a++) {
			if (i & (1 << a)) {
				Count++;
			}
		}
		ans = max(ans, Count);
	}
	cout << ans << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

string r[100], b[100];
int n, m;

int count(string s)
{
  int res = 0;
  rep(i, n) res += s == b[i];
  rep(i, m) res -= s == r[i];
  return res;
}

int main()
{
  int res = 0;
  cin >> n;
  rep(i, n) cin >> b[i];
  cin >> m;
  rep(i, m) cin >> r[i];
  rep(i, n) {
    int t;
    t = count(b[i]);
    res = max(res, t);
  }
  cout << res << endl;
  return 0;
}


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

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class CMaximalValue {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in>> n;
        vector<int> b(n-1);
        rep(i,n-1){
            in >> b[i];
        }
        int ans=0;
        rep(i,n-2){
            ans+=min(b[i],b[i+1]);
        }
        ans+=b[0]+b.back();
	    out << ans << endl;
	}
};


int main() {
	CMaximalValue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int R,L,d,cnt;

int main() {
	cin>>L;
	cin>>R;
	cin>>d;
	
	for (int i = L; i<=R; i++){
		if(i % d == 0){
			cnt++;
		}
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3632
(let ((s (read-line))
      (ans 0))
  (loop :with cnt := 0
        :for c :across s
        :do (cond ((or (char= c #\A) (char= c #\T) (char= c #\C) (char= c #\G))
                   (incf cnt))
                  (t
                   (setf ans (max ans cnt))
                   (setf cnt 0)))
        :finally (setf ans (max ans cnt)))
  (format t "~A~%" ans))


Measured memory_bytes: 24492
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a,b;
    string op;
    int ans;
    
    for (;;){
        cin >> a >> op >> b;
        if ( op == "+"){
            ans = a + b;
        } else if ( op == "-"){
            ans = a - b;
        } else if ( op == "*"){
            ans = a * b;
        } else if ( op == "/"){
            ans = a / b;
        }else {
            break;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int t,n,k,e[100000],s[100000],max=0,sum=0,l1;
  cin>>t;
  for(int i=0;i<t;i++){
    sum=0;
    cin>>n>>k;
    for(int j=0;j<n;j++){
      cin>>e[j];
      if(j==0) sum-=e[j];
      else s[j-1]=e[j]-e[j-1];
      if(j==n-1) sum+=e[j];
    }
    if(n>k){
      for(int j=0;j<k-1;j++){
	max=0;
	for(int l=0;l<n-1;l++){
	  if(s[l]>max){
	    max=s[l];
	    l1=l;
	  }
	}
	sum-=max;
	s[l1]=0;
      }
      cout<<sum<<endl;
    }
    else cout<<0<<endl;
  }
  return 0;
}
   
 
      
 
  
   
  
	
	  
	  
	  
	  
	  
	  
     
  
  
  
  
  

  

 
  


 

    
  



Measured memory_bytes: 3864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int k,x;
    cin>>k>>x;
    REP(i,x-k+1,x+k-1)cout<<i<<sp;
}

Measured memory_bytes: 256
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**15
mod = 10**9+7

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)

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    n,m = LI()
    a = LI()
    uf = UnionFind(n)
    for _ in range(m):
        x,y = LI()
        uf.union(x,y)

    d = collections.defaultdict(list)
    for i in range(n):
        d[uf.find(i)].append(a[i])

    l = len(d)
    if l == 1:
        return 0
    r = 0
    b = []
    for v in d.values():
        v.sort()
        r += v[0]
        b += v[1:]
    b.sort()
    if l % 2 == 0:
        ll = (l // 2 - 1) * 2
    else:
        ll = (l // 2 - 1) * 2 + 1
    if len(b) < ll:
        return 'Impossible'
    r += sum(b[:ll])
    return r



print(main())




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

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

bool isPrime(ll n){
  for(ll i=2;i<100;i++){
    if (n%i==0) return false;
  }return true;
}

int n;
ll tmp, tmp2;
int main(){
  cin >> n;
  long long cnt = 0, sum = 0;
  for(int i=2;;i++){
    if (i%2==0 || i%3==0 || i%5==0){
      if (cnt+2==n && isPrime(sum+i)) continue;
      cout << i << " ";
      cnt++;
      sum += i;
      if (cnt+1==n){
        for(int j=i+1;;j++){
          if ((sum+j)%30==0 && extgcd(sum,j,tmp,tmp2)>1){
            cout << j << endl;
            return 0;
          }          
        }
      }
    }
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{



    ll n;
    cin >> n;
    ll arr[n+1]={0};
    for(ll i=1; i<=n; i++){
        for(ll j=i; j<=n; j+=i){
            arr[j]++;
        }
    }
    ll ans=0;
    for(ll i=1; i<=n; i++){
        ans+=arr[i]*i;
    }
    cout<<ans<<'\n';





}





Measured memory_bytes: 81704
from collections import deque
def main():
    n = int(input())
    c = deque()
    while n:
        n -= 1
        c.appendleft(n % 26)
        n = n // 26
    cs = []
    for ce in c:
        ce += 97
        cec = chr(ce)
        cs.append(cec)
    print("".join(cs))

if __name__ == '__main__':
    main()


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

int main(){
  int N, Y, a, b, c;
  a = -1;
  b = -1;
  c = -1;
  bool finished = false;
  cin >> N >> Y;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N - i; j++){
      if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y){
        a = i;
        b = j;
        c = N - i - j;
        finished = true;
        break;
      }
    }
    if(finished){
      break;
    }
  }
  cout << a << " " << b << " " << c << endl;
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    string goal = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int cnt = 0;
    REP(i,0,16){
        if(goal[i] != s[i]){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> adj(n,vector<bool>(n,true));
    rep(i,0,m) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        adj[u][v] = false;
        adj[v][u] = false;
    }
    vector<bool> vis(n);
    vector<bool> col(n);
    bool bad=false;
    int k=0;
    vi as;
    vi bs;
    rep(i,0,n) if(!vis[i]) {
        queue<int> q;
        int a=0, b=0;
        q.push(i);
        while(!q.empty()) {
            int u = q.front();
            q.pop();
            if(!vis[u]) {
                vis[u] = true;
                if(col[u]) ++a;
                else ++b;
                rep(v,0,n) if(v!=u && adj[v][u]) {
                    if(vis[v]) {
                        if(col[v] == col[u]) bad=true;
                    }
                    else {
                        col[v] = !col[u];
                        q.push(v);
                    }
                }
            }
        }
        ++k;
        as.push_back(a);
        bs.push_back(b);
    }
    if(bad) cout <<"-1\n";
    else {
        vector<bool> pos(n+1);
        pos[0]=true;
        rep(i,0,k) {
            vector<bool> next(n+1);
            rep(j,0,n) if(pos[j]) {
                next[j+as[i]] = true;
                next[j+bs[i]] = true;
            }
            swap(pos,next);
        }
        int best=n*n;
        rep(i,0,n+1) if(pos[i]) {
            best=min(best,i*(i-1)/2+(n-i)*(n-i-1)/2);
        }
        cout << best << "\n";
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    string s; cin >> s;
    int len = s.length();
    REP(i,len){
        cout << "x";
    }
    cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
map <ll,ll> m1;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        m1[2]++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            m1[i]++;
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        m1[n]++;
}  
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    primeFactors(n);
    ll ans=0;
    for (auto x: m1)
    {
        ll val=1,z=x.second;
        // cout<<x.first<<" "<<x.second<<"\n";
        while (z>0)
        {
            z-=val;
            if (z<0)
            {
                bb;
            }
            ans++;
            val++;
        }       
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;cin>>N;
    string S = to_string(N);
    int a=0;
    rep(i,int(S.length())) a += (S[i]-'0');
    if(N%a==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


def solve(a,b,c):
  if a==b and b==c:
    return True
  else:
    return False

a,b,c = map(int, sys.stdin.readline().rstrip().split())
if solve(a,b,c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
  mC = [tuple(map(int, input().split()))
        for _ in range(3)]

  # col
  mD = [[mC[i][j]-mC[i][j+1] for j in range(2)]
        for i in range(3)]
  #print(mD)###

  # row
  mE = [[mC[i][j]-mC[i+1][j] for i in range(2)]
        for j in range(3)]
  #print(mE)###

  res = "Yes"
  if any(vd!=mD[0] for vd in mD[1:]) \
     or any(ve!=mE[0] for ve in mE[1:]):
    res = "No"

  print(res)

main()

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

int main(){
  int N;
  cin >> N;
  vector<ll> vec(N);
    
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  vector<ll> ans(N-1);
  
  for (int i = 0; i < N-1; i++){
    if(vec.at(i) > vec.at(i+1)){
      ans.at(i) = vec.at(i) - vec.at(i+1);
      vec.at(i+1) = vec.at(i);
    }
    else{
      ans.at(i) = 0;
    }
  }
  
  ll a = 0;
  
  for (int j = 0; j < N-1; j++){
    a += ans.at(j);
  }
  
  cout << a << endl;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1) * a % mod;
	else {
		return f1(a * a % mod, p / 2) % mod;
	}
}
int n, d; vector<int>a[123456];
signed main() {
	n = input();
	for1(i, n) a[input()].push_back(i);
	for1(i, n) if (a[i].size() == 2) {
		d = a[i][1] - a[i][0] + 1; d = n + 1 - d;
		break;
	}
	int ans0 = 1, ans1 = 1, ans11 = 1, ans2 = 0;
	for1(i, n + 1) {
		if (i >= 2)ans2 = ans1;
		if (i >= 1)ans1 = ans0;
		ans0 *= n - i; ans0 %= mod; ans0 *= f1(i, mod - 2); ans0 %= mod;
		cout << (ans0 + ans1 * 2 - ans11 + ans2 + mod) % mod;
		printf("\n");
		ans11 *= d - i + 1; ans11 %= mod; ans11 *= f1(i, mod - 2); ans11 %= mod;
	}
}

Measured memory_bytes: 7168
n = int(input())
S = input()

rgb = [[S.count('R'), S.count('G'), S.count('B')]]

if S[0] == 'R':
    rgb[0][0] -= 1
elif S[0] == 'G':
    rgb[0][1] -= 1
else:
    rgb[0][2] -= 1

for i in range(1, n):
    r, g, b = rgb[i-1][0], rgb[i-1][1], rgb[i-1][2]
    if S[i] == 'R':
        r -= 1
    elif S[i] == 'G':
        g -= 1
    else:
        b -= 1
    rgb.append([r, g, b])

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if (S[i] == 'R' and S[j] == 'G') or (S[i] == 'G' and S[j] == 'R'):
            if 2*j-i < n and S[2*j-i] == 'B':
                ans += rgb[j][2] - 1
            else:
                ans += rgb[j][2]
        elif (S[i] == 'R' and S[j] == 'B') or (S[i] == 'B' and S[j] == 'R'):
            if 2*j-i < n and S[2*j-i] == 'G':
                ans += rgb[j][1] - 1
            else:
                ans += rgb[j][1]
        elif (S[i] == 'G' and S[j] == 'B') or (S[i] == 'B' and S[j] == 'G'):
            if 2*j-i < n and S[2*j-i] == 'R':
                ans += rgb[j][0] - 1
            else:
                ans += rgb[j][0]

print(ans)


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

int main(void){
        char x[1001];

        while(1){
                scanf("%s", x);

                int sum = 0, len = 0;
                if(x[0] == '0'){
                        break;
                }else{
                        len = strlen(x);
                        	
                        while(len-- > 0)
                                sum += (x[len] - '0');
                        printf("%d\n", sum);
                }
        }

        return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

ll MOD = 1000000007;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> A(M);
    ll DP[100001];
    memset(DP, 0, sizeof(DP));
    DP[0] = 1;
    bool BROKEN[100001];
    rep(i,M) cin >> A.at(i), BROKEN[A[i]] = true;
    for (int i = 0; i <= N; i++) {
        if (BROKEN[i]) DP[i] = 0;
        else {
            DP[i] %= MOD;
            DP[i+1] += DP[i];
            DP[i+2] += DP[i];
        }
    }
    cout << DP[N] << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == B)
    {
        cout << "Draw";
    }
    else if (A - 1 > 0 && B - 1 > 0)
    {
        if (A - 1 > B - 1)
        {
            cout << "Alice";
        }
        else
        {
            cout << "Bob";
        }
    }
    else
    {
        if (A == 1)
            cout << "Alice";
        else
            cout << "Bob";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;


using f64 = double;
using i64 = long long;
using pii = pair<i64, i64>;

const i64 MOD = 1e9 + 7;
const int N = 1e5 + 5;


vector<pii> g[N], dag[N];
i64 dist[N], in[N], ut[N];
int deg_in[N], deg_ut[N];
bool f[N];

i64 ant;
int n, m, s, t;


static void fix(i64 &x) {
	x = x >= MOD ? x - MOD : x; }

static void dijkstra(int s) {
	priority_queue<pii> pq;
	i64 u, d;

	memset(dist, 0x3f, sizeof dist);
	pq.emplace(0, s);
	dist[s] = 0;

	while (!pq.empty()) {
		pii top = pq.top(); pq.pop();
		tie(d, u) = tie(top.x, top.y);

		if (dist[u] == -d)
		for (auto v: g[u]) if (dist[v.x] > -(d - v.y)) {
			dist[v.x] = -(d - v.y);
			pq.emplace(-dist[v.x], v.x); } } }

static void make_dag(int u) {
	f[u] = true;
	for (auto v: g[u]) if (dist[v.x] == dist[u] - v.y && dist[v.x] < dist[u]) {
		dag[v.x].emplace_back(u, v.y); deg_ut[v.x]+= 1;
		dag[u].emplace_back(v.x, -v.y); deg_in[u]+= 1;
		if (!f[v.x])
			make_dag(v.x); } }

static void dp_in(int u) {
	for (auto v: dag[u]) if (v.y > 0) {
		deg_in[v.x]-= 1;
		in[v.x] = (in[v.x] + in[u]) % MOD;
		if (!deg_in[v.x])
			dp_in(v.x); } }

static void dp_ut(int u) {
	for (auto v: dag[u]) if (v.y < 0) {
		deg_ut[v.x]-= 1;
		ut[v.x] = (ut[v.x] + ut[u]) % MOD;
		if (!deg_ut[v.x])
			dp_ut(v.x); } }

static void magic() {
	i64 cnt, len = dist[t];

	for (int u = 1; u <= n; ++u) if (dist[u] == len - dist[u]) { // for nodes
		cnt = (in[u] * ut[u]) % MOD;
		ant+= cnt * (in[t] - cnt) % MOD; }

	for (int u = 1; u <= n; ++u) // for edges
	for (auto v: dag[u]) if (v.y > 0 && abs((len - dist[v.x]) - dist[u]) < v.y) {
		cnt = (in[u] * ut[v.x]) % MOD;
		ant+= cnt * (in[t] - cnt) % MOD; }


	ant = ((ant % MOD) + MOD) % MOD; }


int main() {
#ifdef HOME
	freopen("arc.in", "r", stdin);
	freopen("arc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	

	cin >> n >> m >> s >> t;
	for (int u, v, c, i = 0; i < m; ++i) {
		cin >> u >> v >> c;
		g[u].emplace_back(v, c);
		g[v].emplace_back(u, c); }

	dijkstra(s);
	make_dag(t);

	in[s] = 1, dp_in(s);
	ut[t] = 1, dp_ut(t);

	magic();

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 30416
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0);  
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
const int mod = 2019;
void test_case(){
	string s; cin>>s;
	int n = s.size();
	int suf = 0;
	map<int,int>cnt;
	cnt[suf]++;
	int ans = 0;
	int power_of_ten = 1;
	for(int i=n-1;i>=0;i--){
		int digit = s[i] - '0';
		suf = (suf + digit * power_of_ten) % mod;
		
		power_of_ten = (power_of_ten * 10) % mod;
		
		ans += cnt[suf];
		cnt[suf]++;
	}
	cout<<ans<<endl;
}
		

signed main(){
	IOS;
	int t=1; //cin>>t;
	while(t--){
		test_case();
	}
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

void main(void)
{
  int A,B,K;
  scanf("%d",&K);
  scanf("%d %d",&A,&B);
  int i=2,flag=0,tmp=K;
  while(K<=B){
    if((A<=K)&&(K<=B)) flag=1;
    
    K=tmp*i;
    i++;
  }
  if(flag>0) printf("OK");
  else printf("NG");
  
}

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

using namespace std;

int a[100005], f[100005];
int k;

int solve(int n) {
	if (n == 0) return 0;
	if (f[n] != -1) return f[n];
	int ans = 1000000009;
	for (int i = 1; i <= k; i++) {
		if (n - i >= 0) {
			ans = min(ans, abs(a[n] - a[n - i]) + solve(n - i));
		}
	}
	return f[n] = ans;
}

int main() {
	int n;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		f[i] = -1;
	}
	printf("%d\n", solve(n - 1));
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A>>B>>K;
    cout<<(A + B + K >= 22 ? "bust" : "win")<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

#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)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

char A[1001][1001];
int main() {
    int H,W; cin>> H >> W;
    set<pair<int,int>>s;
    map<pair<int,int>,bool>mp;
    vector<pair<int,int>>v;
    queue<pair<int,int>>que;
    pair<int, int>last;
    rep(i,H){
        rep(j,W) {
            cin >> A[i][j];
            if(A[i][j]=='#'){
                // s.insert(pair<int,int>(i,j));
                mp[pair<int,int>(i,j)]=true;
                que.push(pair<int,int>(i,j));
            }
        }
    }

    last=que.back();
    int num=0;
    while(mp.size()!=H*W){;
        while(true){
            pair<int,int>k=que.front();
            que.pop();
            int a=k.first, b=k.second;
            for(int i=0; i<4; i++){
                if(0<=a+dx[i] && a+dx[i]<=H-1 && 0<=b+dy[i] && b+dy[i]<=W-1){
                    if(!mp[pair<int,int>(a+dx[i], b+dy[i])]) {
                        mp[pair<int,int>(a+dx[i], b+dy[i])]=true;
                        que.push(pair<int, int>(a + dx[i], b + dy[i]));
                    }
                }
            }
            if(k==last){
                last=que.back();
                break;
            }
        }
        num++;
    }

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 71952
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n--){
    string str;
    set<string> st;
    cin >> str;
    for(int i=0;i<str.size();i++){
      string s1 = str.substr(0,i),s2 = str.substr(i);
      for(int k=0;k<2;k++){
        for(int l=0;l<2;l++){
          st.insert(s1 + s2);
          st.insert(s2 + s1);
          reverse(s1.begin(),s1.end());
        }
        reverse(s2.begin(),s2.end());
      }
    }
    cout << st.size() << endl;
  }
}

Measured memory_bytes: 1288
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // ee or eXe だけなのでそれがないかをチェック
        int s2Index = 0;
        int s1Index = 1;
        char s2 = s.charAt(s2Index); //2個前
        char s1 = s.charAt(s1Index); //1個前
        if (s1 == s2) {
            out.println(++s2Index + " " + ++s1Index);
            return;
        }


        for (int s0Index = 2; s0Index < s.length(); s0Index++) {
            char s0 = s.charAt(s0Index);

            // ee
            if (s1 == s0) {
                out.println(++s1Index + " " + ++s0Index);
                return;
            }

            // eXe
            if (s2 == s0) {
                out.println(++s2Index + " " + ++s0Index);
                return;
            }


            s2Index = s1Index;
            s1Index = s0Index;
            s2 = s1;
            s1 = s0;
        }

        out.println("-1 -1");
    }
}

Measured memory_bytes: 25812
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int k;string s;cin>>k>>s;
  if(s.size()>k) {for(int i=0; i<k; ++i) cout<<s[i]; cout<<"..."<<endl;}
  else cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> like(m+1);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			like[a]++;
		}
	}
	int res = 0;
	for (int i = 0; i < m + 1; i++) {
		if (like[i] == n)res++;
	}
	cout << res << endl;

}

Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]

X=[None for i in range(n)]

first=0
sig=1

for i in range(n):
    first+=A[i]*sig
    sig*=-1
    
X[0]=first

for i in range(n-1):
    X[i+1]=2*A[i]-X[i]

#print(X)

ans=[str(X[i]) for i in range(n)]

ans=" ".join(ans)

print(ans)

Measured memory_bytes: 19144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC148A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b;
			a = int.Parse(Console.ReadLine());
			b = int.Parse(Console.ReadLine());
			int c = 6 - a - b;
			Console.WriteLine(c);
		}
	}
}

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

int main(){
    long long n, m, v, p;
    cin >> n >> m >> v >> p;

    int d = -1;
    int h = n - 1;

    int a[n];
    int pos[n];
    for(int i = 0; i<n; i++){
        cin >> a[i];
    }

    sort(a, a + n);
    int cur, val;
    val = -1;
    for(int i = n - 1; i>=0; i--){
        if(a[i] != val){
            val = a[i];
            cur = i;
        }

        pos[i] = cur;
    }

    while(h > d + 1){
        int mid = (d + h) / 2;
        int md = mid;
        mid = pos[mid];
        long long cnt = 0;
        int ptr = mid;
        int b[n];
        int inc[n];
        fill(inc, inc + n, 0);
        for(int i = 0; i<n; i++) b[i] = a[i];

        b[mid] += m;
        cnt += m;

        while(1){


            ptr += n - 1;
            ptr %= n;
            if(ptr == mid) break;
            inc[ptr] = max(0LL, min(b[mid] - (long long)a[ptr], m));
            b[ptr] =  max((long long)a[ptr], min((long long)b[mid], a[ptr] + m));
            cnt += inc[ptr];

            if(cnt >= m*v) break;
        }

        for(int i = n - 1; i>mid; i--){
                //cout << cnt << endl;
            if(cnt < m*v){
                cnt += (a[i] + m) - b[i];
                b[i] = a[i] + m;
            }

            else break;
        }
    /*
        if(mid == 2){
            for(int i = 0; i<n; i++){
                cout << b[i] << " ";
            }
        }
        */

        int big = 0;
        for(int i = 0; i<n; i++){
            if(b[i] > b[mid]) big++;
        }

        if(big <= p - 1) h = md;
        else d = md;
    }

    cout << n - h << endl;


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll x,y,z,n,m=0,i,j,k,p,q;

    cin>>n>>k;
 n=n%k;
 cout<<min(n,k-n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
signed main(){
    int n;
  cin>>n;
    string s[100001];
    int a=0,b=0,c=0,d=0;
    rep(i,n){
        cin>>s[i];
        if(s[i]=="AC")a++;
        if(s[i]=="WA")b++;
        if(s[i]=="TLE")c++;
        if(s[i]=="RE")d++;
        
    }
  cout<<"AC x "<<a<<endl;
        cout<<"WA x "<<b<<endl;
        cout<<"TLE x "<<c<<endl;
        cout<<"RE x "<<d<<endl;
        return 0;
}


Measured memory_bytes: 6740
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 xx[5];
	cin >> xx[0] >> xx[1] >> xx[2] >> xx[3] >> xx[4];
	for(int64 ii = 0;ii < 5;ii++)
	{
		if(!xx[ii])
		{
			cout << (ii + 1) << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int par[100005],r[100005]={},size[100005];

void init(int n){
  int i;
  for (i=0;i<n;i++){
    par[i]=i;
    size[i]=1;
  }
}

int root(int a){
  if (par[a]==a) return a;
  return par[a]=root(par[a]);
}

void unite(int a,int b){
  a=root(a);
  b=root(b);
  if (a==b) return;
  if (r[a]<r[b]){
    par[a]=b;
    r[b]++;
    size[b]+=size[a];
  }else{
    par[b]=a;
    r[a]++;
    size[a]+=size[b];
  }
}


int main(void){
  int n,m,i,a[100005],b[100005],ar,br;
  
  cin >> n >> m;
  for (i=0;i<m;i++) cin >> a[i] >> b[i];
  
  init(n);
  
  ll ans[100005]={};
  ans[m-1]=(ll)n*(n-1)/2;
  for (i=m-1;i>0;i--){
    ar=root(a[i]);
    br=root(b[i]);
    if (ar!=br){
      ans[i-1]=ans[i]-(ll)size[ar]*size[br];
      unite(ar,br);
    }else{
      ans[i-1]=ans[i];
    }
  }
  
  for (i=0;i<m;i++) cout << ans[i] << endl;
  
  return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int x,a,b;
  bool flag = false;
  cin >> x;
  for(int i=-118;i<=119;i++) {
    for(int j=-119;j<=118;j++) {
        if(pow(i,5)-pow(j,5) == x) {
            flag = true;
            a = i;
            b = j;
            break;
        }
    }
  }
  if(flag)
    cout << a << " " << b;
}

Measured memory_bytes: 4064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
#include <iomanip>
#include <limits>

//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

using namespace std;
int main() {
	int N;
	int K;
	cin >> N;
	cin >> K;
	int k;
	int j;
	long double ans = 0;
	int res = 0;

	for (int i = 1; i <= N; i++) {
		k = i;
		while (k < K) {
			k = 2 * k;
			res = res + 1;
		}
		long double b = powl(0.5, res);
		res = 0;
		ans = b + ans;
		  b = 0;
	
	}
	
	long double d = N;
	cout << setprecision(13) << ans / d << endl;


}





Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    if (n <= k) {
        cout << x * n << endl;
    } else {
        cout << x * k + y * (n - k) << endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), w(n);
  vector<int> r, l;
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    cin >> w[i];
    if (a[i]) {
      l.push_back(w[i]);
    } else {
      r.push_back(w[i]);
    }
  }
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  if (l.size() == 0 || r.size() == 0) {
    cout << 0 << endl;
  } else {
    cout << r[0] + l[0] << endl;
  }
  return 0;
}



Measured memory_bytes: 3172