akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  int sum = 0;
  int sum2 = 0;

  for(int i=0;i<N;++i){
    int d;
    cin >> d;
    sum += d;
    sum2 += d*d;
  }

  cout << (sum*sum-sum2)/2 << endl;
}


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

int main()
{
    // S H C D
    int card[52] = {0};
    int n;
    cin >> n;
    rep(i, n)
    {
        int l;
        char s;
        cin >> s >> l;
        l--;
        if (s == 'S')
            card[l] = 1;
        else if (s == 'H')
            card[13 + l] = 1;
        else if (s == 'C')
            card[26 + l] = 1;
        else if (s == 'D')
            card[39 + l] = 1;
    }
    rep(i, 52)
    {
        if (card[i] == 0)
        {
            int j = i / 13;
            int r = i % 13;
            if (j == 0)
                cout << "S " << r + 1 << endl;
            if (j == 1)
                cout << "H " << r + 1 << endl;
            if (j == 2)
                cout << "C " << r + 1 << endl;
            if (j == 3)
                cout << "D " << r + 1 << endl;
        }
    }
}


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

const int INF = 1e9;

int main() {
  string s;
  cin>>s;
  int max_len=0;
  int tmp_len=0;
  for(char c: s){
    if(c=='A'||c=='T'||c=='G'||c=='C') {
      ++tmp_len;
    } else{
      max_len=max(max_len,tmp_len);
      tmp_len=0;
    }

  }
  max_len=max(max_len,tmp_len);
  cout<<max_len<<endl;;

}

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

int main() {
  int n;
  cin >> n;
  vector<long long int> a(n+1), b(n);
  for(int i = 0; i < n+1; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
  }

  long long int count;
  for(int i = 0; i < n; i++){
    if (b.at(i) > a.at(i)){
      if (a.at(i+1) >= b.at(i) - a.at(i)) {
        count += b.at(i);
        a.at(i+1) -= b.at(i) - a.at(i);
      } else {
        count += a.at(i) + a.at(i+1);
        a.at(i+1) = 0;
      }
    } else {
      count += b.at(i);
      a.at(i) -= b.at(i);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  int ans = 0;
  int positive = 0;
  int negative = 0;
  rep(i,n){
    if(i == 0) ans -= A[i];
    else if(i == n-1) ans += A[i];
    else{
      if(A[i] < 0) ans -= A[i];
      else ans += A[i];
    }
    if(A[i] > 0) positive++;
    else negative++;
  }
  cout << ans << endl;
  int tmp = 0;
  if(positive == 0){
    reverse(A.begin(),A.end());
    rep(i,n-1){
      if(i == 0){
        cout << A[i] << " " << A[i+1] << endl;
        tmp = A[i] - A[i+1];
      }
      else{
        cout << tmp << " " <<  A[i+1] << endl;
        tmp -= A[i+1];
      }
    }
  }
  else if(negative == 0){
    rep(i,n-1){
      if(i == 0){
        cout << A[i] << " " <<  A[i+1] << endl;
        tmp = A[i] - A[i+1]; 
      }
      else if(i == n-2){
        cout << A[i+1] << " " << tmp << endl;
      }
      else{
        cout << tmp << " " << A[i+1] << endl;
        tmp -= A[i+1];
      }
    }
  }
  else{
    for(int i = negative + 1;i < negative + positive;i++){
      if(i == negative + 1){
        cout << A[0] << " " <<  A[i] << endl;
        tmp = A[0] - A[i];
      }
      else{
        cout << tmp << " " << A[i] << endl;
        tmp -= A[i];
      }
      A[0] = tmp;
    }
    for(int i = 0;i < negative;i++){
      cout << A[negative] << " " << A[i] << endl;
      A[negative] -= A[i];
    }
  }
}

Measured memory_bytes: 2688
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    xx = input_ints()
    print(xx.index(0)+1)


main()


Measured memory_bytes: 9012
fun main(args: Array<String>) {
    abc134d()
}

fun abc134d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ")
        .map { it == "0" }

    val ballInBoxes = BooleanArray(n)

    (n - 1 downTo 0).forEach { index ->
        var currAi = index + 1
        var sumModIsZero = true
        while ((currAi - 1) < n) {
            if (ballInBoxes[currAi - 1]) sumModIsZero = !sumModIsZero
            currAi += (index + 1)
        }

        if (aList[index] != sumModIsZero) ballInBoxes[index] = true
    }

    val count = ballInBoxes.count { it }
    println(count)

    if (count > 0) {
        println(ballInBoxes.withIndex().filter { it.value }.map { it.index + 1 }.joinToString(" "))
    }
}


Measured memory_bytes: 79856
# 79
# ABC106 D


def solve():
    N, M, Q = map(int, input().split())
    LR_L = tuple([int(x) for x in input().split()] for y in range(M))
    Q_L = tuple([int(x) for x in input().split()] for y in range(Q))

    imos_l = [[0] * (N+2) for _ in range(N+1)]

    for l, r in LR_L:
        imos_l[l][l] += 1
        imos_l[l][r+1] -= 1
    for i in range(1, N+1):
        for j in range(1, N+2):
            imos_l[i][j] += imos_l[i][j-1]

    for p, q in Q_L:
        ans = 0
        for i in range(p, q+1):
            ans += imos_l[i][i] - imos_l[i][q+1]
        print(ans)


solve()


Measured memory_bytes: 129580
n = int(input())
a = []
i = 0
while i < n:
    a.append(list(map(int, input().split())))
    i += 1

a.sort(key = lambda x: x[1])

i = 0
t = 0
while i < n:
    t += a[i][0]
    if t > a[i][1]:
        break
    i += 1

print("Yes" if i >= n else "No")

Measured memory_bytes: 53716
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, c, s, f;
    cin >> n;
    vector<vector<int>> arr;
    for(int i = 0; i < n-1; i++) {
        cin >> c >> s >> f;
        arr.push_back({c, s, f});
    }
    for(int i = 0; i < n-1; i++) {
        int t = 0;
        for(int j = i; j < n-1; j++) {
            int f = arr[j][2];
            t = max(t, arr[j][1]);
            t = (1 + (t-1)/ f) * f + arr[j][0];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}




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

int main()
{
    const int BUILDINGS = 4;
    const int FLOORS = 3;
    const int ROOMS = 10;
    int house[BUILDINGS+1][FLOORS+1][ROOMS+1];

    string border(20,'#');

    int n;
    int b, f, r, v;

    memset(house, 0, sizeof(house));

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;

        house[b][f][r] += v;
    }

    for(int i = 1; i <= BUILDINGS; i++)
    {
        if(i != 1)
            cout << border << endl;
        for(int j = 1; j <= FLOORS; j++)
        {
            for(int k = 1; k <= ROOMS; k++)
            {
                cout << ' ' << house[i][j][k];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int d;
  cin>>d;
  string a,b;
  cin>>a>>b;
  int c=0;
  rep(i,a.size()){
  rep(j,a.size()-i){
  if(a[j+i]!=b[j]){
  break;
  }
   else if(j==a.size()-i-1){
   c=a.size()-i;
    goto A;
   }
  }
  }
  A:
cout<<2*d-c<<endl;
}

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

int main() {
  ll a, b, v, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  if (v > w && abs(a - b) <= t * (v - w)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int main() {
    ll b;
    while (cin >> b) {
        if ( ! b) break;
        pair<ll,ll> ans = {1, b};

        vector<ll> d1;
        for (ll i=1; i*i<=b; ++i) {
            if (b % i == 0) {
                if ((b/i) % 2) d1.push_back(i);
                if (i % 2 && i*i != b) d1.push_back(b/i);
            }
        }
        for (ll m: d1) {
            pair<ll,ll> t = {b/m, m-(b/m)/2};
            if (1 <= t.second) ans = max(ans, t);
        }

        vector<ll> d2;
        ll b2 = 2*b;
        for (ll i=1; i*i<=b2; ++i) {
            if (b2 % i == 0) {
                if (i % 2 && (b2/i) % 2 == 0) d2.push_back(i);
                if (i % 2 == 0 && (b2/i) % 2 && i*i != b2) d2.push_back(b2/i);
            }
        }
        for (ll m2: d2) {
            pair<ll,ll> t = {b2/m2, m2/2-((b2/m2)-1)/2};
            if (1 <= t.second) ans = max(ans, t);
        }

        cout << ans.second << " " << ans.first << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
const int D = __lg(N) + 1;
int x[N],pa[N][D];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> x[i];
    int l,q;
    cin >> l >> q;
    for (int i = 1, j = 0; i < n; ++i) {
        while (x[i] - x[j] > l)
            ++j;
        pa[i][0] = j;
        for (int k = 1; k < D; ++k)
            pa[i][k] = pa[pa[i][k-1]][k-1];
    }
    for (int i = 0; i < q; ++i) {
        int a,b;
        cin >> a >> b;
        if (b < a)
            swap(a,b);
        --a,--b;
        int ans = 0;
        for (int j = D-1; j >= 0; --j)
            if (pa[b][j] > a) {
                ans |= 1<<j;
                b = pa[b][j];
            }
        if (b > a)
            ++ans;
        cout << ans << '\n';
    }
}


Measured memory_bytes: 7936
#include<stdio.h>

int main(){

	int j,n,i,x[10]={},z,p;
	
	while( scanf("%d",&n) != EOF){
		for(i=0;i<10;i++){
			x[i]=n%2;
			n=n/2;
		}
		for(i=0;i<10;i++){
			z=0;
			if(x[i]==1){
				z=1;
				if(i==0){
					printf("%d",z);
				}
				if(i!=0){
					for(j=1;j<=i;j++){
						z=z*2;
						if(i==j){
							printf("%d",z);
						}
					}
				}
				z=0;
				for(j=i+1;j<=9;j++){
					if(x[j]==0){
						z=z+1;
					}
				}
				p=9-z;
				if(p==i){
					printf("\n");
				}
				else if(p!=i){
					printf(" ");
				}
			}
		}
	}

return 0;
}

Measured memory_bytes: 600
h,w=map(int,input().split())
n=int(input())
a=list(map(str,input().split()))

pre=[]
for i in range(n):
    for j in range(int(a[i])):
        pre.append(str(i+1))
for i in range(h):
    if i%2==1:
        sub=pre[w*(i+1)-1:w*i-1:-1]
        pre[w*i:w*(i+1)]=sub
for i in range(h):
    print(' '.join(pre[w*i:w*(i+1)]))

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

int main(){
    int n;
    cin >> n;
    int v[n],c[n];
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        int x=0,y=0,tans;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                x += v[j];
                y += c[j];
            }
        }
        tans = x-y;
        if(tans > ans){
            ans = tans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll> vec(1000010,0);
  for(ll i=1;i<=N;i++){
    for(ll j=1;i*j<=N;j++){
      vec[i*j]++;
    }
  }
  ll ans=0;
  for(int i=1;i<N;i++){
    ans+=vec[i];
  }
  cout << ans <<endl;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i,n){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    rep(i,k){
        ans += l.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3560
a,b,c,d,e,f = map(int, input().split())
g = max(a, b)
h = min(a, b)
salt = []
water = []
concentration = 0

for i in range(int(e*f/(c*100)) + 1):
    j = 0
    while e*f/100 >= c*i +d*j:
        salt.append(c*i+d*j)
        j += 1
salt.sort()

for i in range(int(f/(100*g)) + 1):
    j = 0
    while f >= 100*(g*i+h*j):
        water.append(100*(g*i+h*j))
        j += 1
water.sort()
water = water[1:]

for i in range(len(water)):
    addsalt = min(water[i] * e // 100, f - water[i])
    while addsalt not in salt:
        addsalt -=1
    if concentration < addsalt / (water[i] + addsalt):
        concentration = addsalt / (water[i] + addsalt)
        salt1 = addsalt
        water1 = water[i]

try:
    print(salt1+water1, salt1)
except NameError:
    print(water[0], 0)

Measured memory_bytes: 13400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		System.out.println(A+B >= C ? "Yes" : "No");
	}
}



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

using namespace std;

int main(){
    long long h;
    cin>>h;
    
    long long cnt=1;
    
    while(h>1){
        h=h/2;
        cnt++;
    }
    
    long long ans=pow(2,cnt)-1;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4068
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		String o=sc.next();
		String e=sc.next();
		int lo=o.length();
		int le=e.length();
		StringBuffer buf= new StringBuffer();
		int a=0;
		int b=0;
		while(a!=lo) {
			buf.append(o.substring(a,a+1));
			a++;
			if(b!=le) {
				buf.append(e.substring(b,b+1));	
				b++;
			}
		}
		
		String ans=buf.toString();;
		System.out.println(ans);
		
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define good {puts("No");return 0;}
#define Hao {puts("Yes");return 0;}
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

inline void upmin(int &x,const int &y){if(y<x) x=y;}
inline void upmax(int &x,const int &y){if(y>x) x=y;}

int a[100010],n;

int main()
{
    n=read();
    int mn=n+1,mx=0;
    for(int i=1;i<=n;i++)
    {
        a[i]=read();
        upmin(mn,a[i]);
        upmax(mx,a[i]);
    }
    if(mx>mn+1) good
    if(mx==mn)
    {
        if(mn==n-1) Hao
        if(2*mn<=n) Hao
        else good
    }
    else
    {
        int cnt=0;
        for(int i=1;i<=n;i++) cnt+=(a[i]==mn);
        if(mn<cnt) good
        if(n-cnt<2*(mx-cnt)) good
        else Hao
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
#include <bits/stdc++.h>
int main() {
    int n;
    cin >> n;
    vector <int> a(n) , b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    int t = n / 2;
    sort(b.begin() , b.end());
    for(int i = 0; i < n; i++){
        if(a[i] < b[t]){
            cout << b[t] << endl;
        }
        else{
            cout << b[t - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4800
X = ARGF.gets.chomp.to_i

ans = 
  if X <= 599
    8
  elsif X <= 799
    7
  elsif X <= 999
    6
  elsif X <= 1199
    5
  elsif X <= 1399
    4
  elsif X <= 1599
    3
  elsif X <= 1799
    2
  else
    1
  end

puts ans




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

int main(void)
{
	char a[7],b[4];
	scanf("%s%s",a,b);
	strcat(a,b);
	if((int)pow((int)sqrt(atoi(a)),2)==atoi(a))puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool n = false, w = false, s = false, e = false;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'N') n = true;
    else if (S.at(i) == 'W') w = true;
    else if (S.at(i) == 'S') s = true;
    else e = true;
  }
  if (((n && s) || (!(n) && !(s))) && ((w && e) || (!(w) && !(e)))) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
main(){
	char s[4];
	int cup[3]={1,0,0},i,j,t;
	while(~scanf("%s",s)){
		i=s[0]-'A',j=s[2]-'A';
		t=cup[i],cup[i]=cup[j],cup[j]=t;
	}
	for(i=0;i<3;i++)cup[i]&&printf("%c\n",'A'+i);
	exit(0);
}

Measured memory_bytes: 0
k, a, b = map(int,input().split())

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(bsk)
        return
    else:
        k -= (a-1)
        bsk = a

    if k>=2:
        if k%2==0:
            bsk += (b-a)*(k//2)
        else:
            bsk += (b-a)*((k-1)//2)+1
    
    print(int(bsk))
    
    
f(k,a,b)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

ll mem[100];

ll func(ll n) {
	if (n == 0) return 2;
	if (n == 1) return 1;
	if (mem[n] != 0) return mem[n];
	return mem[n] = func(n - 1) + func(n - 2);
}

int main() {
	ll n; cin >> n;
	cout << func(n) << endl;
	return 0;
}

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;
typedef vector<string> vs;

#define SZ(x) ((int)(x).size())

#define fill(x,y) memset(x,y,sizeof(x))

// with compile option -DLOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

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

#define pcnt __builtin_popcount
#define pcntll __builtin_popcountll

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n;
    cin >> n;
    vi a;
    rep(n) {
        int val;
        cin >> val;
        a.pb(val);
    }

    int ret = 0;
    rep(n){
        if(n == 0) continue;
        if(a[i - 1] == 10001) continue;
        if(a[i] == a[i - 1]) {
            ret++;
            a[i] = 10001;
        }
    }

    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
s = input()
n = len(s)
a = [0] * (n+1)

for i in range(n):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in reversed(range(n)):
    if s[i] == '>':
        a[i] = max(a[i], a[i+1] + 1)
print(sum(a))

Measured memory_bytes: 23336
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


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

  int N = S.length();

  int cnt = 0;

  for(int i=0; i<N/2; i++){
    if(S[i] != S[N-1-i]){
      cnt += 1;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;
void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll x=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		x^=a[i];
	}
	for(ll i=0;i<n;i++)
	{
		ll ans=x^a[i];
		cout<<ans<<" ";
	}
	cout<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4776
import math

a,b,x=map(int,input().split())
if x<=(a**2)*b/2:
    l=(2*x)/(a*b)
    ans=math.atan(b/l)
else:
    d=2*b-(2*x)/(a**2)
    ans=math.atan(d/a)
print(math.degrees(ans))

Measured memory_bytes: 38384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){

  ll A, B, C; cin >> A >> B >> C;
  int ans = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
    ll a = (B + C) / 2, b = (C + A) / 2, c = (A + B) / 2;
    ans++;
    A = a; B = b; C = c;
    if (a == b && b == c){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    d=dict()
    for i in range(N):
        s=readline().strip()
        if s not in d:
            d[s]=1
        else:
            pass
    
    print(len(d))

if __name__=="__main__":
    main()

Measured memory_bytes: 35272
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,x[26]{},x1[26],y;
	string s[50];
	for(int b=0;b<26;b++)x1[b]=1000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		y=s[i].size();
		for(int j=0;j<y;j++){
			x[s[i][j]-'a']++;
			}
		for(int k=0;k<26;k++){
			if(x1[k]>=x[k])x1[k]=x[k];
			}
		for(int a=0;a<26;a++)x[a]=0;
		}
	for(int l=0;l<26;l++){
		for(int m=0;m<x1[l];m++){
			cout<<(char)('a'+l);
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if not n and not x:
        break
    count = 0
    for a in range(1, n+1):
        for b in range(1, a):
            for c in range(1, b):
                if a + b + c == x:
                    count += 1
    print(count)



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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long K, long long A, long long B) {
    loop (i, 1, 1000) {
        if (A <= K * i && K * i <= B) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
    return;
}

int main() {
    long long K;
    scanf("%lld", &K);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(K, A, B);
    return 0;
}


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

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

    vector<long long int> div1;
    for (long long int i=1; i*i<=n-1; i++){
        if ((n-1) % i == 0){
            div1.push_back(i);

            long long int j = (n-1) / i;
            if (j != i) div1.push_back(j);
        }
    }
    long long int ans = div1.size() - 1;// removed 1

    vector<long long int> div2;
    for (long long int i=2; i*i<=n; i++){
        if (n % i == 0) div2.push_back(i);
    }

    int m = div2.size();
    for(int i=0; i<m; i++){
        long long int a = n;
        while(a > 0){
            if(a % div2[i] == 0) a /= div2[i];
            else break;
        }
        if(a % div2[i] == 1) ans += 1;
    }
    ans += 1;// self
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main(){
  int N; cin>>N;
  vector<char> S(N);
  for(int i=0; i<N; i++){
    cin>>S.at(i);
  }
  int A=0; int B=0; int C=0; int D=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='P')
      A++;
   else if(S.at(i)=='W')
      B++;
   else if(S.at(i)=='G')
      C++;
 else   if(S.at(i)=='Y')
      D++;
  }
  if(A!=0&&B!=0&&C!=0&&D!=0)
    cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//↑templete
int main() {
	int N;
	cin>>N;
	string S;
	cin>>S;
	int M[SIZE][SIZE]={};
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(S[i]!=S[j])
				continue;
			if(M[i][j]>=j-i)
				continue;
			M[i+1][j+1]=M[i][j]+1;
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans=max(ans, M[i+1][j+1]);
		}
	}

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

Measured memory_bytes: 99968
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
  int t, n, h, hh, dmax, umax;

  cin >> t;
  for (int j = 0; j < t; j++) {
    dmax = 0;
    umax = 0;
    cin >> n;
    cin >> hh;
    for (int i = 1; i < n; i++) {
      cin >> h;
      if (h - hh > 0 && h - hh > umax) {
        umax = h - hh;
      }
      if (hh - h > 0 && hh - h > dmax) {
        dmax = hh - h;
      }
      hh = h;
    }
    cout << umax << " " << dmax << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    
    int K;
    cin >> K;

    int L = s.size();
    set <string> X;
    for (int i = 0; i < L; i++) {
        for (int j = 1; j <= 5 && i + j <= L; j++) {
            //printf("i=%d j=%d\n", i, j);
            X.insert(s.substr(i, j));
        }
    }
    
    for (int i = 1; !X.empty(); i++) {
       // cout << i << endl;
        //cout << *begin(X) << endl;
        if (i == K) {
            cout << *begin(X);
            break;
        }
        X.erase(*begin(X));
    }
}


Measured memory_bytes: 1664
N,K=map(int,input().split())

A=[]

for _ in range(K):
    di=int(input())
    #for _ in range(di):
    A_t=list(map(int,input().split()))
    for i in range(di):
        A.append(A_t[i])    

print(N-len(set(A)))



Measured memory_bytes: 9176
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int d;
  int i;

  while ( scanf ( "%d", &d ) == 1 )
  {
    int res = 0;

    for ( i = d; i < 600; i += d )
    {
      res += i * i * d;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();void print(){cout<<'\n';}template<class T,class ...U>void print(T x, U ...y){cout<<x<<' ';print(y...);}
typedef long long ll; typedef long double db;
const int N = 2e5 + 5, M = 1e9 + 7;
ll qpow(ll x, ll n) { ll res = 1; for (; n; n >>= 1, x = x * x % M) if (n & 1) res = res * x % M; return res; }

ll fac[N];
ll comb(ll n, ll m) {
  return fac[n] * qpow(fac[m] * fac[n-m] % M, M - 2) % M;
}

ll sum[N], siz[N], ans[N];
vector<int> G[N];

void dfs(int u, int f) {
  sum[u] = 1;
  for (int v : G[u]) {
    if (v == f) continue;
    dfs(v, u);
    siz[u] += siz[v];
    sum[u] = sum[u] * comb(siz[u], siz[v]) % M * sum[v] % M;
  }
  siz[u]++;
}

int n;

void sol(int u, int f) {
  ans[u] = sum[u];
  for (int v : G[u]) {
    if (v == f) continue;
    ll tsum = sum[v];
    sum[v] = sum[v] * comb(n - 1, siz[v] - 1) % M * sum[u] % M * qpow(comb(n - 1, siz[v]) * sum[v] % M, M - 2) % M;
    sol(v, u);
    sum[v] = tsum;
  }
}

int main() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < N; i++) {
    fac[i] = fac[i-1] * i % M;
  }
  int u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  sol(1, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\n';
  }
}


Measured memory_bytes: 20212
import sys
from collections import deque
def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        A, B = map(int, input().split())
        G[A].append(B)
        G[B].append(A)
    ans = [0] * (N + 1)
    ans[1] - 1
    cnt = 1
    q = deque([1])
    while q:
        v = q.popleft()
        for to in G[v]:
            if ans[to] > 0: continue
            ans[to] = v
            q.append(to)
            cnt += 1
    if cnt < N:
        print('No')
        return
    print('Yes')
    for i in range(2, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 34032
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	int n;
	int a[] = new int[201];

	//最大操作回数を指定
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();

	//1回目に黒板に書かれる数字を指定
	for(int i = 0; i < n; i++){
	    a[i] = sc.nextInt();
	}

	int count = 0; //何回計算できるのか保持する変数
	
	//偶数かどうか判別する
	while(true){
	    //existOddをfalseで初期化し，
	    boolean existOdd = false;

	    //奇数でない(偶数である)場合はtrueを入れる
	    for(int i = 0; i < n; i++){
		if(a[i] % 2 != 0){
		    existOdd = true;
		}
	    }
	    //奇数があれば終了する
	    if(existOdd) break;
	    
	    //全て偶数の時，操作を行う
	    for(int i = 0; i < n; i++){
		a[i] /= 2;
	    }
	    //回数のカウント
	    count++;
	}
	//実行結果を表示する
	System.out.println(count);
    }
    
}


		
	    
	       
	


Measured memory_bytes: 23252
fun main() {
    val n = nextInt()

    var ans = 0L
    (1..n).forEach { x ->
        val y = n / x
        ans += y.toLong().times(y.plus(1)).times(x).div(2)
    }
    println(ans)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

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

#define MAX_H 50
#define MAX_W 50

int main() {
    int H, W;
    cin >> H >> W;
    char field[MAX_H+1][MAX_W+1];
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }
    int dxs[3] = {-1, 0, 1};
    int dys[3] = {-1, 0, 1};
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            int count = 0;
            if (field[h][w] == '.') {
                for (int i = 0; i < 3; i++) {
                    int dx = dxs[i];
                    for (int j = 0; j < 3; j++) {
                        int dy = dys[j];
                        int ny = h + dy, nx = w + dx;
                        if (0 <= nx && nx < W && 0 <= ny && ny < H && field[ny][nx] == '#') {
                            count++;
                        }
                    }
                }
                field[h][w] = (char)('0' + count);
            }
        }
    }
    // output
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cout << field[h][w];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int n, G[N][N];
int c[N], d[N], f[N], t;

void visit(int u)
{
  int i;
  c[u] = 1;
  d[u] = ++t;
  for(i = 0; i < n; i++)
    {
      if(G[u][i] == 0)
	{
	  continue;
	}
      if(c[i] == 0)
	{
	  visit(i);
	}
    }
  c[u] = 2;
  f[u] = ++t;
}

void dfs()
{
  int i;
  for(i = 0; i < n; i++)
    {
      c[i] = 0;
    }
  t = 0;
  for(i = 0; i < n; i++)
    {
      if(c[i] == 0)
	{
	  visit(i);
	}
    }
  for(i = 0; i < n; i++)
    {
      printf("%d %d %d\n", i+1, d[i], f[i]);
    }
}

int main()
{
  int i, j, k, u, v;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      for(j = 0; j < n; j++)
	{
	  G[i][j] = 0;
	}
    }

  for(i = 0; i < n; i++)
    {
      scanf("%d %d", &u, &k);
      u--;
      for(j = 0; j < k; j++)
	{
	  scanf("%d", &v);
	  v--;
	  G[u][v] = 1;
	}
    }
  dfs();
  return 0;
} 



Measured memory_bytes: 2056
c =[]
c = [list(map(int,input().split())) for _ in range(3)]
count=0
for i in range(2):
    for j in range(2):
        if (c[i][j]+c[i+1][j+1]) == (c[i][j+1] + c[i+1][j]):
            count += 1
if count == 4:
    print('Yes')
else:
    print('No')

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

const int MAX_V = 100000;
const int INF = (1 << 31);

class Edge {
public:
  int t, w;
  Edge(int t, int w): t(t), w(w) {}
};

int D[MAX_V];
int N;

vector<Edge> G[MAX_V];

void bfs(int u) {
  for (int i = 0; i < N; i++) D[i] = INF;

  queue<int> Q;
  Q.push(u);
  D[u] = 0;

  while (!Q.empty()) {
    u = Q.front(); Q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      Edge e = G[u][i];
      if (D[e.t] == INF) {
        D[e.t] = D[u] + e.w;
        Q.push(e.t);
      }
    }
  }
}

void solve() {
  bfs(0);

  int dia = 0;
  int target = 0;

  for (int i = 0; i < N; i++) {
    if (D[i] == INF) continue;
    if (dia < D[i]) {
      dia = D[i];
      target = i;
    }
  }

  bfs(target);

  dia = 0;

  for (int i = 0; i < N; i++) {
    if (D[i] == INF) continue;
    dia = max(dia, D[i]);
  }

  cout << dia << endl;
}

int main() {
  cin >> N;

  for (int i = 0; i < N-1; i++) {
    int s, t, w; cin >> s >> t >> w;
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }

  solve();

  return 0;
}

Measured memory_bytes: 7988
import math

s = int(input())
heiho = math.ceil(math.sqrt(s))

x1 = heiho
x2 = 1
y1 = heiho**2-s
y2 = heiho
x3 = 0
y3 = 0
l =map(str, [x1, y1, x2, y2, x3, y3])


print(" ".join(l))

Measured memory_bytes: 3064
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, P = getIntList()
#print(N)
if N==1:
    print(P)
    sys.exit()
r = 1
for  t in range(2,1000003):
    if P%t!=0: continue
    c = 0
    while P%t==0:
        P//=t;
        c+=1
    r *= t ** (c//N)

print(r)


Measured memory_bytes: 41800
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "functional"
#include "stack"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, L, R, H, W;



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

	string s;
	getline(cin, s);
	while (s != "#") {
		int v[3] = {};
		int index = 0;
		//cout << s << endl;
		for (int i = 7; i < s.size(); i++) {
			//cout << i <<" "<<index<< endl;
			if (s[i] == ' ') {
				index++;
			}
			else {
				v[index] *= 10;
				v[index] += s[i] - '0';
			}
		}
		string ret;
		if (v[0] <= 30 || (v[0] == 31 && v[1] <= 4)) {
			ret += "HEISEI " + to_string(v[0]) + " " + to_string(v[1]) + " " + to_string(v[2]);
		}
		else {
			ret += "? " + to_string((v[0] - 30)) + " " + to_string(v[1]) + " " + to_string(v[2]);
		}
		cout << ret << endl;
		getline(cin, s);
	}
}


Measured memory_bytes: 3232
#include<stdio.h>
main()
{
	int a,b,sum;
	scanf("%d %d",&a,&b);
	sum = a+b;
	if(sum<3)
	{
		printf("Impossible\n");
	}
	else 
	{
		if(a%3==0 || b%3==0 || sum%3==0)
		{
			printf("Possible\n");
		}
		else 
		{
			printf("Impossible\n");
		}
	}
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int64_t mod = 1e9 + 7;
	int N;
	cin >> N;
	vector<vector<int> > a(N,vector<int>(N));
	for (auto& ai : a)
		for (auto& aij : ai)
			cin >> aij;
	function<int(int)> popCount = [](int a) {
		int res = 0;
		while (a)
		{
			a &= a - 1;
			++res;
		}
		return res;
	};

	vector<int64_t> dp(1 << N);
	dp[0] = 1;
	fore(i,1, dp.size()-1)
	{
		int p = popCount(i);
		int newNode = p - 1;
		forn(j, N)
		{
			if (((1 << j) & i) && a[j][p-1])
			{
				int rem = i - (1 << j);
				dp[i] += dp[rem];
				if (dp[i] >= mod)
					dp[i] -= mod;
			}
		}
	}

	cout << dp.back() << endl;

	return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <math.h>
#include <fenv.h>
using namespace std;

int main(){
    long long int N,ans;
    float num;
    cin>>N;
    ans=0;
    for(int i=1;i<=N;i++){
        if(fmod((float)i,3.0)==0.0 || fmod((float)i,5.0)==0.0){

        }else{
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<vector>
using namespace std;
int abs(int n){
    if(n < 0){
        return -n;
    }
    return n;
}

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;

    int w = Y-X;

    vector<vector<int> > D(N, vector<int>(N));
    vector<int> cnt(N);
    for(int i=0; i<N; i++){
        for(int j=i;j<N;j++){
            D.at(i).at(j) = min(abs(j-i), min(abs(j-(Y-1))+abs(i-(X-1))+1, abs(j-(X-1))+abs(i-(Y-1))+1) );
            cnt.at(D.at(i).at(j)) += 1;
            // cout << D.at(i).at(j) << " ";
        }
        // cout << endl;
    }
    int ans = N;

    for(int i=1;i<N;i++){
        cout << cnt.at(i) << endl;
        
    }
    
}

Measured memory_bytes: 16000
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(){
    int n, cnt=0;
    cin >> n;
    while(n>2){
        int m=0;
        m=n%3;
        n/=3;
        if(m!=0){
            n++;
        }
        cnt++;
        //cout << n << endl;
    }
    if(n==2)cnt++;
    cout << cnt << endl;
    
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	cin >> n;
	rep(q, n){
		string s;
		cin >> s;
		int h, m;
		h = stoi(s.substr(0, 2)); m = stoi(s.substr(3, 2));
		double a, b;
		a = 360/(60./m); b = 360/(12./h) + 30/(60./m);
		if(abs(a-b) < 30 || abs(abs(a-b)-360) < 30) cout << "alert" << endl;
		else if(abs(a-b) < 90 || abs(abs(a-b)-360) < 90) cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<int> res;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vector<vector<int>> field(n, vector<int>(5));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> field[i][j];
            }
        }
        int cnt = 0;
        bool update = true;
        while (update) {
            update = false;
            bool col[5];          
            for (int i = 0; i < n; i++) {
                for (int i = 0; i < 5; i++) {
                    col[i] = false;
                }
                for (int j = 1; j <= 3; j++) {
                    if (field[i][j] != 0 and field[i][j - 1] == field[i][j] and field[i][j] == field[i][j + 1]) {
                        update = true;
                        col[j - 1] = col[j] = col[j + 1] = true;
                    }
                }
                for (int j = 0; j < 5; j++) {
                    if (col[j]) {
                        cnt += field[i][j];
                        field[i][j] = 0;
                    }
                }
            }
            for (int i = n - 2; i >= 0; i--) {
                for (int j = 0; j < 5; j++) {
                    int cur = i;
                    while (cur < n - 1 and field[cur + 1][j] == 0) {
                        swap(field[cur][j], field[cur + 1][j]);
                        cur++;
                    }
                }
            }
        }
        res.push_back(cnt);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3168