akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    bit = input()[::-1]
    count = bit.count("1")
    count_plus = count+1
    count_minus = count-1
    pow_plus = [1 % count_plus]
    for i in range(n):
        pow_plus.append(pow_plus[-1]*2 % count_plus)
    if count_minus != 0:
        pow_minus = [1 % count_minus]
        for i in range(n):
            pow_minus.append(pow_minus[-1]*2 % count_minus)
    else:
        pow_minus = []

    bit_plus = 0
    bit_minus = 0

    for i in range(n):
        if bit[i] == "1":
            bit_plus = (bit_plus+pow_plus[i]) % count_plus
    if count_minus != 0:
        for i in range(n):
            if bit[i] == "1":
                bit_minus = (bit_minus+pow_minus[i]) % count_minus
    ans = []
    for i in range(n):
        if bit[i] == "1":
            if count_minus == 0:
                ans.append(0)
                continue
            bit_ans = (bit_minus-pow_minus[i]) % count_minus
            count = count_minus
        else:
            bit_ans = (bit_plus+pow_plus[i]) % count_plus
            count = count_plus
        cnt = 1
        while bit_ans:
            b = str(bin(bit_ans)).count("1")
            bit_ans = bit_ans % b
            cnt += 1
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)


main()


Measured memory_bytes: 28444
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(int argc, char const *argv[]) {
  int n;
  int i,j,k;
  int *lens;
  int sum;
  int a,b,c;

  scanf("%d", &n);
  lens = (int*)(malloc(sizeof(int) * n));
  for(i = 0; i < n; i++){
    scanf("%d", &lens[i]);
  }
  qsort(lens, n, sizeof(int), compare_int);
  sum = 0;
  i = 0;
  while(i <= n - 2 && n >= 3){
    a = lens[i];
    for(j = i+1; j < n-1; j++){
      b = lens[j];
      for(k = j+1; k < n; k++){
        c = lens[k];
        if(c < a + b){
          if(b < c + a){
            if(a < b + c){
              sum++;
            }
          }
        }
      }
    }
    i++;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 252
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int determine[200000] = {};
int changed[200000] = {};
int main() {
	int n;
	cin >> n;
	vector<int> a, t;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		t.push_back(tmp);
	}
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	changed[0] = true;
	determine[0] = t[0];
	for (int i = 1;i < n;++i) {
		if (t[i] != determine[i - 1]) changed[i] = true;
		determine[i] = t[i];
	}
	a.push_back(-1);
	for (int i = n - 1;i >= 0;--i) {
		if (a[i] != a[i + 1]) {
			if (changed[i] == true) {
				if (determine[i] != a[i]) {
					cout << "0" << endl;
					return 0;
				}
			}
			changed[i] = true;
			if (a[i] > determine[i]) {
				cout << "0" << endl;
				return 0;
			}
		}
		determine[i] = min(determine[i], a[i]);
	}
	long long ans = 1;
	for (int i = 0;i < n;++i) {
		if (changed[i] == false) {
			ans *= determine[i];
			ans %= MAX_MOD;
		}
	}
	cout << ans%MAX_MOD << endl;
	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (A <= C && C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}






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

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if (a - b - w > 0) {
		cout << a - b - w << endl;
	}
	else {
		if(b - a - w > 0){
			cout << b - a - w << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int gcd(int x, int y)
{
    if (x % y)
    {
        return gcd(y, x % y);
    }
    else
    {
        return y;
    }
}
int main()
{
    int x, y, g;
    scanf("%d%d", &x, &y);
    g = gcd(x, y);
    x /= g;
    y /= g;
    printf("%d\n", g + 1 + (x + y - 2) * g);
}



Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;
const lli inf = 1e18;
typedef pair<lli, lli> pll;

lli solve(int v, int k, int prev, vector<bool> &used, vector<vector<int> > &adj){
    used[v] = true;
    lli ret = 1;
    lli curr = 0;
    for(int next: adj[v]){
        if(used[next]) curr++;
    }

    ret *= k-prev-curr;
    ret %= mod;
    for(int next: adj[v]){
        if(used[next]) continue;
        ret *= solve(next, k, curr, used, adj);
        ret %= mod;
        curr++;
    }
    //cout << "ret = " << ret << endl;
    return ret;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int> > adj(n);
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<bool> used(n, false);
    cout << solve(0, k, 0, used, adj) << endl;
    return 0;
}

Measured memory_bytes: 11648
#include <stdio.h>
#include <string.h>
int main()
{
    long long int i,l,sum=0;
    char str[1000000];
    scanf("%s",str);
    l=strlen(str);
    for(i=0;i<l;i++)
    {
        str[i]-=48;
        sum+=str[i];
    }
    if(sum%9==0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}

Measured memory_bytes: 1856
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) cin >> a[i];
	if (a[0] == a[1]) cout << a[2] << endl;
	else if (a[0] == a[2]) cout << a[1] << endl;
	else cout << a[0] << endl;
}

Measured memory_bytes: 256
t = input()
n = t.count('N')
s = t.count('S')
w = t.count('W')
e = t.count('E')

if (n>0 and s>0 and w>0 and e>0)or(n==0 and s==0 and w>0 and e>0) or (n>0 and s>0 and w==0 and e==0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
int check(int n)
{
    int c=1;
    while(n)
    {
        if(n%10!=7){c=0;break;}
        n=n/10;
    }
    return c;
}
signed main(){
    fast

  int n;
  cin>>n;
  string s;
  int c=0,d=0;
  cin>>s;
  f0(i,0,n)
  {
      if(s[i]=='R')c++;
      else d++;
  }int e=0;
  f0(i,0,c)
  {
    if(s[i]!='R')e++;  
  }
  cout<<e<<endl;
  
}

Measured memory_bytes: 3732
def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  B = [1 + (A[i] - 1) * 0.5 for i in range(N)]
  total = sum(B[0:K])
  answer = total
  for i in range(N - K):
    total += B[i + K] - B[i]
    answer = max(answer, total)
  print(answer)
solve()

Measured memory_bytes: 24816
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1ll << 60;

int main(){
    int n; cin>>n;
    vector<int> h(n);
    vector<ll> dp(1e5+10,INF);
    for(int i=0; i<n; i++) cin>>h[i];
    
    dp[0]=0;

    for(int i=0; i<n; i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int wa[51][11];

struct team{
	int ac, pe, id;
	bool operator<(const team& a) const{
		if(ac != a.ac) return ac > a.ac;
		if(pe != a.pe) return pe < a.pe;
		if(id != a.id) return id > a.id;
	}
};

int main(){
	int i, j, M, T, P, R, m, t, p, ju;
	vector<team> set(51);
	while(1){
		cin >> M >> T >> P >> R;
		if(!M)break;
		for(i=0;i<=T;i++){
			set[i].ac = 0;
			set[i].pe = 0;
			set[i].id = i;
			for(j=1;j<=P;j++){
				wa[i][j] = 0;
			}
		}
		for(i=0;i<R;i++){
			cin >> m >> t >> p >> ju;
			if(!ju){
				set[t].ac++;
				set[t].pe += wa[t][p] * 20 + m;
			}
			else wa[t][p]++;
		}
		sort(set.begin()+1, set.begin()+1+T);
		for(i=1;i<=T;i++){
			if(i>1){
				if(set[i-1].ac==set[i].ac && set[i-1].pe==set[i].pe){
					cout << "=";
				}
				else cout << ",";
			}
			cout << set[i].id;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
	
	long long int n,k;
	cin>>n>>k;
	long long int i,arr[n],ans=0;
	for(i=0;i<n;i++){
	    cin>>arr[i];
	    ans=ans+arr[i];
	}
	sort(arr,arr+n,greater<int>());
	i=0;
	while(i<k && i<n){
	    ans=ans-arr[i];
	    i++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  vi s(n);

  rep(i, n) cin >> s[i];
  sort(all(s));

  int sum = accumulate(all(s),0);
  if (sum % 10) {
    cout << sum << endl;
    return (0);
  }

  rep(i, n) {
    if (s[i] % 10) {
      cout << sum - s[i] << endl;
      return (0);
    }
  }

  cout << 0 << endl;
  
  return (0);
}

Measured memory_bytes: 3612
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt(),color=gInt();
		long[][]cost=new long[color][color];
		int[][]a=new int[n][n];
		
		int[][]sum=new int[3][color];
		
		for(int i:rep(color))
			for(int j:rep(color))
				cost[i][j]=gInt();
		for(int i:rep(n)) {
			for(int j:rep(n)) {
				int v=gInt()-1;
				int p=(i+j)%3;
				++sum[p][v];
			}
		}
		
		long res=Long.MAX_VALUE;
		for(int i:rep(color))
			for(int j:rep(color))
				for(int k:rep(color))
					if(i!=j&&j!=k&&k!=i)
						res=Math.min(res,f(i,j,k,cost,sum));
					
		System.out.println(res);
	}
	private long f(int c1,int c2,int c3,long[][] cost,int[][] sum){
		int[]v= {c1,c2,c3};
		long r=0;
		for(int i:rep(3)) {
			r+=REP(cost.length)
					.mapToLong(j->cost[j][v[i]]*sum[i][j])
					.sum();
		}
		return r;
	}
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if(B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b, c, d, e, f;

  cin >> a >> b >> c >> d >> e >> f;

  if(a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000)
  {
    cout << 1 << endl;
  }
  else
  {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

A,B = inpl()
if A*B%2 == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 20692
#include <stdio.h>
#include <stdlib.h>

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int main( void ) {
	int i;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int data[ 10000 ];
		long long sum;

		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );
		qsort( data, n, sizeof(int), &compare );

		sum = 0LL;
		for ( i = 0; i < n; i++ )
			sum += data[ i ] * ( n - i - 1 );

		printf( "%lld\n", sum );
	}

	return 0;
}

Measured memory_bytes: 716
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cr = 0;
  int cl = 0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0') cr++;
    else cl ++;
  }
  int ans = min(cr,cl) * 2;
  cout << ans << endl;
  return 0;
}


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

int main()
{
        int A[3];
        
    cin >> A[0] >> A[1] >> A[2];
        
        sort(A,A+3);
        
        cout << A[0]  << " "<< A[1] << " " << A[2] << endl;
    

}

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

int main(){
  int N;
  cin >> N;
  
  int a=N/1000;
  int b=(N-1000*a)/100;
  int c=(N-1000*a-100*b)/10;
  int d=N-1000*a-100*b-10*c;
  
  if(a==b&&b==c){
    cout << "Yes" << endl;
  }
  else if(b==c&&c==d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
# coding:utf-8

import math
import re

def main(params):
    r,d,x = params[0].split()
    r = int(r)
    d = int(d)
    x = int(x)
    base = 2000
    for i in range(1,11):
        newX = r * x - d
        print newX
        x = newX
#    a = params[1].split()
#    b = list(params[2])

if __name__ == "__main__":
    cnt = 1 # TODO: edit here
    params = []
    for i in range(cnt):
        param = raw_input()
        params.append(param)
    main(params)



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

int main(int argc, char const *argv[])
{
  int N,A,ans; // N,A : 問題文通りの定義 / ans : 答え
  cin >> N; // Nを格納
  ans = 1000; // 最終的な答えは最小値なので、まずはどんな答えよりも大きい数字を代入

  for (int i = 0; i < N; ++i)
  {
    cin >> A; // A_iをAに格納
    int tmpAns = 0; // A_iに対する「最大で何回 2 で割れるか」の値。最初は0

    while(A%2 == 0){ // Aを2で割れるかぎり
        tmpAns++; // 割れる回数を+1して
        A = A / 2; // Aには2で割った数値を再代入
    }

    if (tmpAns < ans){ // tmpAnsがansより小さければansに代入 →ansはtmpAnsの最小値となる
        ans = tmpAns;
    }
  }

  cout << ans << endl; // 答えを出力
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

int n, m;
vector<ll> d, t;

int main(){
    cin >> n;
    REP(i, n){
        int di;
        cin >> di;
        d.push_back(di);
    }

    cin >> m;
    REP(i, m){
        int ti;
        cin >> ti;
        t.push_back(ti);
    }

    sort(d.begin(), d.end());
    sort(t.begin(), t.end());

    int tmp_d = 0;
    bool flag = true;
    REP(i, m){
        while(1){
            if(t[i]==d[tmp_d]){
                tmp_d += 1;
                break;
            } else if (t[i] < d[tmp_d]){
                flag = false;
                break;
            } else {
                tmp_d += 1;
            }
        }
    }

    if(flag){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 4848
#include<stdio.h>
#include<string.h>
#define MAX 100

void queen(int);

int n;
int row[MAX], col[MAX], up_right[MAX], down_right[MAX];
char bord[8][8];

int main(){
  int r, c;

  //盤面の初期化
  for(r = 0 ; r < 8 ; r++){
    for(c = 0 ; c < 8 ; c++){
      bord[r][c] = '.';
    }
  }

  scanf("%d", &n);
  for(int i = 0 ; i < n ; i++){
    scanf("%d%d", &r, &c);
    
    bord[r][c] = 'Q';
    row[r] = 1;
    col[c] = 1;
    up_right[r + c] = 1;
    down_right[r - c + 7] = 1;
  }

  queen(0); 

  return 0;
}

void queen(int r){
  int i, j;
  int c;

  if(r == 8){
    for(i = 0 ; i < 8 ; i++){
      for(j = 0 ; j < 8 ; j++){
	printf("%c", bord[i][j]);
      }
      printf("\n");
    } 
    return;
  }

  if(row[r] == 1) queen(r + 1);

  for(c = 0 ; c < 8 ; c++){
    if(row[r] == 0 && col[c] == 0 && up_right[r + c] == 0 && down_right[r - c + 7] == 0){
      bord[r][c] = 'Q';
      row[r] = 1;
      col[c] = 1;
      up_right[r + c] = 1;
      down_right[r - c + 7] = 1;
      queen(r + 1);
      bord[r][c] = '.';
      row[r] = 0;
      col[c] = 0;
      up_right[r + c] = 0;
      down_right[r - c + 7] = 0;     
    }
  }
}




Measured memory_bytes: 2112
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long As[] = new Long[N];
        for(int i = 0;i < N;i++)
            As[i] = sc.nextLong();
        long L[] = new long[N];
        long R[] = new long[N];
        ArrayList<Long> M = new ArrayList(Collections.nCopies(N,0));

        for(int i = 0;i < N - 1;i++)
            L[i + 1] = gcd(L[i],As[i]);
        for(int i = N - 1;i > 0;i--)
            R[i - 1] = gcd(R[i],As[i]);
        for(int i = 0;i < N;i++)
            M.set(i,gcd(L[i],R[i]));

        System.out.println(max(M));
    }

    public static long max(List<Long> ar){
        long max = 0;
        for(int i = 0; i< ar.size();i++)
            if(max < ar.get(i))
                max = ar.get(i);
        return max;
    }

    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }


    public static long gcd(long m, long n) {
        if(m == 0)
            return n;
        if(n == 0)
            return m;
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}





Measured memory_bytes: 61568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
cin >> n;
string a;
cin >> a;
int count;
count = 0;
for (int i = 0; i < n-2; i++){
if (a.substr(i, 3)=="ABC"){count ++;}
}
cout << count;
}

Measured memory_bytes: 256
N,K = (int(x) for x in input().split())
t_arr = [0]*(N+1)
d_arr = [0]*(N+1)
for i in range(N):
    t,d = tuple(int(x) for x in input().split())
    t_arr[i+1] = t
    d_arr[i+1] = d

td_index = list(range(1,N+1))
td_index.sort(key=lambda x:d_arr[x], reverse=True)

n_dm_set = set()
small_arr = []
d_dm = 0
for i in td_index[:K]:
    t = t_arr[i]
    d = d_arr[i]
    if t in n_dm_set:
        small_arr.append(d)
    n_dm_set.add(t)
    d_dm += d

current_max = len(n_dm_set)**2+d_dm

n_x_set = set(n_dm_set)
d_x = d_dm
nt_x = len(n_dm_set)
for i in td_index[K:]:
    if not small_arr:
        break
    t = t_arr[i]
    d = d_arr[i]
    if t in n_x_set:
        continue
    n_x_set.add(t)
    d_x += d
    d_x -= small_arr.pop()
    nt_x += 1
    current_max = max(current_max, nt_x**2+d_x)

print(current_max)


Measured memory_bytes: 20532
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K, ans, mi, A;
string s;
int main() {
	cin >> N;
	vector<LL> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());


	
	cout << b[N/2]-b[(N/2)-1] << endl;
						return 0;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int func(vector<vector<int>> v, int n, int m, vector<int> p) {
	int res = 0;
	rep(bit, (1 << n)) {
		bool b = true;
		rep(i,m) {
			vector<int> u = v[i];
			int temp = 0;
			for (int j: u) {
				if ((bit & (1 << j))) temp++;
			}
			if (!(temp % 2 == p[i])) b = false;
		}
		if (b) res++;
	}
	return res;
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> v(m);
	rep(i,m) {
		int k;
		cin >> k;
		v[i].resize(k);
		rep(j,k) {
			cin >> v[i][j];
			v[i][j]--;
		}
	}
	vector<int> p(m);
	rep(i,m) cin >> p[i];
	int ans = func(v, n, m, p);
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int count = 0;
		while (x <= y / 2) {
			count++;
			x *= 2;
		}
		System.out.println(count + 1);
	}
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number = Integer.parseInt(sc.next());
    String str = sc.next();
    if(number >= 3200) {
      System.out.println(str);
    } else {
      System.out.println("red");
    }
  }
}


Measured memory_bytes: 23636
while True:
    n = int(input())
    if n == 0:
        break
    word1 = word2 = ""
    for i in range(n):
        a, b = input().split()
        word1 += a
        word2 += b
    q = int(input())
    s = ""
    for i in range(q):
        s+=input().rstrip()
    print(s.translate(str.maketrans(word1, word2)))


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

int main() {
	vector<int> buyable(101,0);
	for(int i = 0 ;;i++){
		for(int j = 0 ;;j++){
			if(4*i+7*j <= 100){
				buyable[4*i+7*j] = 1;
			}else{
				break;
			}
		}
		if(4*i >= 100) break;
	}
	int n; cin >> n;
	if(buyable[n] == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, n;
    cin >> n >> m;
    ll ans = 0;
    priority_queue<pair<int, int> > q;
    rep (i, n) {
      int a;
      cin >> a;
      q.push(make_pair(a, 1));
    }
    rep (i, m) {
      int b, c;
      cin >> b >> c;
      q.push(make_pair(c, b));
    }
    rep (i, n) {
      pair<int, int> p;
      p = q.top();
      q.pop();
      p.second--;
      ans += p.first;
      if (p.second > 0) q.push(p);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[300030], invf[300030];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	int n, k;
	cin>>n>>k;
	ll a[100010];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a, a+n);
	ll ans=0;
  fac(n);
	for(int i=0; i<=n-k; i++){
		ans+=(MOD-(a[i]+MOD)*comb(n-i-1, k-1)%MOD);
		ans%=MOD;
	}
	for(int i=k-1; i<n; i++){
		(ans+=(a[i]+MOD)*comb(i, k-1))%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

string s;

int N;

int ans1=-1, ans2=-1;

 bool CHECK2(string s) {

	for (int i = 2; i <= N; i++) {
		if (s[i] == s[i - 1]) { 
			ans1 = i - 1;
			ans2 = i;
			return true; }
	}
	return false;
}

 bool CHECK3(string s) {
	 for (int i = 3; i <= N; i++) {
		 if (s[i] == s[i - 2]) {
			 ans1 = i - 2;
			 ans2 = i;
			 return true;
		 }
	 }
	 return false;
 }
int main(void) {

	cin >> s;

	N = s.size();

	s = "#" + s;

	if (CHECK2(s)) { cout << ans1 << " " << ans2 << endl; }
	else if (CHECK3(s)) { cout << ans1 << " " << ans2 << endl; }
	else { cout << -1 << " " << -1 << endl; }

	//system("pause");
	return 0;
}

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

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




Measured memory_bytes: 3088
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a[3];
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main() {
  int n,x; 
  cin >> n >> x;
  int ans;
  cin>>ans;
  ans=abs(ans-x);
  rep(i,n-1){
    int tmp; cin>>tmp;
    tmp = abs(tmp-x);
    ans = gcd(ans,tmp);
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if(isalpha(ch)){
			if(isupper(ch)){
				printf("%c",tolower(ch));
			}else{
				printf("%c",toupper(ch));
			}

		}else{
			printf("%c",ch);
		}

		if(ch == '\n') break;
	}
	return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

vector<vector<int>> to;
vector<int> memo;

int dfs(int i){
	int &r = memo[i];
	if(r < 0){
		r = INT_MAX;
		for(int j = 0; j < 26; ++j){
			r = min(r, dfs(to[j][i]) + 1);
		}
	}
	return r;
}

int main(){
	string a;
	cin >> a;
	int n = a.size();
	to.assign(26, vector<int>(n + 1, n + 1));
	for(int i = n - 1; i >= 0; --i){
		for(int j = 0; j < 26; ++j){
			to[j][i] = to[j][i + 1];
		}
		to[a[i] - 'a'][i] = i + 1;
	}

	memo.assign(n + 2, -1);
	memo[n + 1] = 0;

	int rest = dfs(0);
	string ans;
	for(int p = 0; rest > 0; --rest){
		int j;
		for(j = 0; memo[to[j][p]] != rest - 1; ++j);
		p = to[j][p];
		ans += char('a' + j);
	}
	cout << ans << '\n';
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, k, q;

  cin >> n >> k >> q;
  vector<int> cnt(n);





  for(int i = 0; i < q; i++) {

     int a;
     cin >> a;
     cnt[a-1]++;
  }

  int temp = k - q;

  for(int i = 0; i < n; i++) {

     if(cnt[i]) {

        if(temp + cnt[i] > 0) {

            cout << "Yes" << endl;
        }
        else {

            cout << "No" << endl;
        }
     }
     else {

        if(temp <= 0) {

            cout << "No" << endl;
        }
        else {

            cout << "Yes" << endl;
        }
     }
  }

}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int w[501][501];
int main()
{
    int n,m,q,i,j,l,r,p,t;
    cin>>n>>m>>q;
    for(i=1;i<=m;i++)
    {
        cin>>l>>r;
        w[l][r]++;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            w[i][j]=w[i][j]+w[i][j-1]+w[i-1][j]-w[i-1][j-1];
        }
    }
    for(i=1;i<=q;i++)
    {
        cin>>p>>t;
        cout<<w[n][t]-w[p-1][t]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1920
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
//    int[] height = new int[n];
    int max = 0;
    int res = 0;
    for (int i=0;i<n;i++) {

      int height = cin.nextInt();
      if (height >= max) {
        res++;
        max = height;
      }

    }
    System.out.println(res);
  }

}


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

int bit[100001], n, q;
void add(int k, int x) {
	while (k <= n) {
		bit[k] += x;
		k += k&-k;
	}
}
int sum(int k) {
	int res = 0;
	while (k > 0) {
		res += bit[k];
		k -= k&-k;
	}
	return res;
}
int main() {
	scanf("%d%d", &n, &q);
	rep(i, q) {
		int a; scanf("%d", &a);
		if (a) {
			int b; scanf("%d", &b);
			printf("%d\n", sum(b));
			continue;
		}
		int s, t, x; scanf("%d%d%d", &s, &t, &x); t++;
		add(s, x); add(t, -x);
	}
}

Measured memory_bytes: 3528
h,w,n = gets.split.map(&:to_i)
hs = Hash.new(0)
ans = [(h-2)*(w-2)] + [0]*10
n.times{
  a,b = gets.split.map(&:to_i)
  (a..(a+2)).each{|i| (b..(b+2)).each{|j| ans[hs[i*(10**9+7)+j]+=1]+=1 if 2<i&&i<=h&&2<j&&j<=w}}
}
ans.inject{|i,j| p i-j;j}

Measured memory_bytes: 60028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

void solve(void){
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    Rep(1, N, b){
        //cout << ans << '\n';
        ans += max(0, b-K)*(N/b)+max(0,N%b-K+1)-(K==0?1:0);
    }
    cout << ans << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int a[5];
    int ans = 0;
    rep(i,5){
        cin >>a[i];
        if(a[i] == 0){
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3596
#include<stdio.h>

int island[50][50];
int W,H;

void dfs(int y,int x){
  int i,j,nx,ny;
  island[y][x]=0;

  for(i=-1;i<2;i++){
    for(j=-1;j<2;j++){
      if(i==0 && j==0)
	continue;
      ny=y+i;
      nx=x+j;
      if(ny < 0 || nx < 0 || ny > H-1 || nx > W-1)
	continue;
      if(island[ny][nx]!=1)
	continue;
      dfs(ny,nx);
    }
  }
  
}

int main(){
  int ans=0;
  int i,j;
  
  while(scanf("%d %d",&W,&H),H+W!=0){

    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	scanf("%d",&island[i][j]);
      }
    }

    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(island[i][j]==0)
	  continue;
	ans++;
	dfs(i,j);
      }
    }

    printf("%d\n",ans);
    ans=0;
  }
  
  return 0;
}

Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
void tiranga() {
    int n;
    cin >> n;
    int arr[100003];
    lp(i, n) cin >> arr[i];
    int Max = INT_MIN;
    int step = 0;
    lp(i, n-1) {
        if (arr[i + 1] <= arr[i])
            step++;
        else {
            Max = max(Max, step);
            step = 0;
        }
    }
    Max = max(Max, step);
    cout << Max;
}
int main() {
#ifndef ONLINE_JUDGE.
    //freopen("input.txt", "r", stdin);
#else
#endif
    
    origi();
    tiranga();
    //cout << sumOfDig(123654);
   // genLarge(10, 10);
   // genSmall(10);

}


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

int main() {
  while (true) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0) return 0;
    int ans = 0;
    map<string, bool> used;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        int k = x - i - j;
        vector<int> a({i, j, k});
        sort(all(a));
        string cand = "";
        rep(i, 3) { cand += to_string(a[i]) + ","; }
        if (0 < k && k < n && k != j && k != i && !used[cand]) {
          ++ans;
          used[cand] = true;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0, can = 1e9;
  for (int i = 0, s; i < N && cin >> s; i++) {
    if (s % 10) can = min(can, s);
    ans += s;
  }
cout << ((ans % 10) ? ans : (can != 1e9) ? ans - can : 0) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 3648
import Data.List
import Control.Monad.State

main = do
    [n, m] <- map read . words <$> getLine
    xss <- map (map read . tail . words) <$> sequence (replicate n getLine)
    print . fst $ runState (acnt n m xss) (replicate m 0) 

acnt :: Int -> Int -> [[Int]] -> State [Int] Int
acnt n m [] = length . filter (==n) <$> get
acnt n m [xs] = state $ \s ->
    let xs' = map (\x -> if x `elem` xs then 1 else 0) [1..m]
        s' = zipWith (+) xs' s
        in (length . filter (==n) $ s', s')
acnt n m (xs:xss) = do
    acnt n m [xs]
    acnt n m xss
    s <- get
    return (length . filter (==n) $ s)


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll mod = inf;
ll dp[3001][3001];
ll pt[3001][3001];
ll nm[3001];
vector<pair<int,int> > v;

void init(){
    for(int i=0;i<3001;i++){
        pt[i][0] = 1;
        pt[i][i] = 1;
    }
    for(int i=2;i<3001;i++){
        for(int j=1;j<i;j++){
            pt[i][j] = (pt[i-1][j-1] + pt[i-1][j])%mod;
        }
    }
    return;
}


ll saiki(int i,int s){
    if(dp[i][s]!=0)return dp[i][s];
    if(i==v.size()-1){
        return pt[v[i].second-v[i].first+1][s+nm[i]];
    }
    ll ans = 0;
    int tmp = s+nm[i];
    if(v[i].second < v[i+1].first){
        return dp[i][s] = (pt[v[i].second-v[i].first+1][tmp]*saiki(i+1,0))%mod;
    }else{
        for(int j=max(0,tmp-(v[i].second-v[i+1].first+1));j<=min(tmp,v[i+1].first-v[i].first);j++){
            ans = (ans + (pt[v[i+1].first-v[i].first][j] * saiki(i+1,tmp-j))%mod ) %mod;
        }
    }
    return dp[i][s] = ans;
}





int main(){
    init();
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    int l,r;
    cin >> l >> r;
    v.PB(MP(l,r));
    for(int i=0;i<m-1;i++){
        cin >> l >> r;
        if(v[v.size()-1].first==l){
            if(r>v[v.size()-1].second){
                v[v.size()-1].second =r;
            }
        }else{
            if(r>v[v.size()-1].second){
                v.PB(MP(l,r));
            }
        }
    }
    // for(int i=0;i<v.size();i++){
    //     cout << v[i].first << " " <<v[i].second << endl;
    // }
    for(int i=1;i<v.size();i++){
        int tmp = 0;
        if(v[i].first>v[i-1].second){
            for(int j=v[i].first;j<=v[i].second;j++){
                if(s[j-1]=='1'){
                    tmp++;
                }
            }
        }else{
            for(int j=v[i-1].second+1;j<=v[i].second;j++){
                if(s[j-1]=='1'){
                    tmp++;
                }
            }
        }
        nm[i] = tmp;
        //cout << i << " " <<  nm[i] << endl;
    }
    int tmp = 0;
    for(int i=v[0].first;i<=v[0].second;i++){
        if(s[i-1]=='1'){
            tmp++;
        }
    }
    //cout << tmp << endl;
    if(v.size()==1){
        cout << pt[v[0].second-v[0].first+1][tmp] << endl;
        return 0;
    }
    ll ans = 0;
    if(v[0].second <v[1].first){
        //cout << pt[v[0].second-v[0].first+1][tmp] << endl;
        ans = (pt[v[0].second-v[0].first+1][tmp]*saiki(1,0))%mod;
    }else{
        for(int i=max(0,tmp-(v[0].second-v[1].first+1));i<=min(tmp,v[1].first-v[0].first);i++){
            ans = (ans + (pt[v[1].first-v[0].first][i] * saiki(1,tmp-i))%mod ) %mod;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 99072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
char a[11001],c;
int main()
{
	cin>>a;
	int t=strlen(a);
	for(int i=0;i<t;i++)
	{
		if(a[i]=='x')c++;
		}
	if(c>=8)printf("NO");
	else printf("YES");	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3005;

int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
double dp[N][N];
double p[N];
int n;
double go(int pos,int heads)
{
    if(pos==n+1)
    {
        return heads>n/2;
        
    }
    double &ans=dp[pos][heads];
    if(ans!=-1)
        return ans;
    ans=0;
    ans+=p[pos]*go(pos+1,heads+1);
    ans+=(1-p[pos])*go(pos+1,heads);
    return ans;
}
int32_t main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=-1.0;
        }
    }
    cout<<fixed<<setprecision(12)<<go(1,0)<<endl;





    
}

Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
vector<int> vec[150010];
int cnt[150010];
long double ansdown[150010];
long double ans[150010];
bool bl[150010];

void dfs(int x) {
	bl[x] = true;
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (!bl[vec[x][i]]) {
			dfs(vec[x][i]);
			cnt[x]++;
			ansdown[x] += ansdown[vec[x][i]] + 1;
		}
	}
	if (cnt[x])ansdown[x] /= cnt[x];
}

void dfs2(int x) {
	bl[x] = true;
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (!bl[vec[x][i]]) {
			if (cnt[x] == 1)ans[vec[x][i]] = (ansdown[vec[x][i]] * cnt[vec[x][i]] + 1) / (cnt[vec[x][i]] + 1);
			else ans[vec[x][i]] = ((ans[x] * cnt[x] - ansdown[vec[x][i]] - 1) / (cnt[x] - 1) + 1 + ansdown[vec[x][i]] * cnt[vec[x][i]]) / (cnt[vec[x][i]] + 1);
			cnt[vec[x][i]]++;
			dfs2(vec[x][i]);
		}
	}
}

signed main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs(1);
	ans[1] = ansdown[1];
	fill(bl, bl + n + 5, false);
	dfs2(1);
	for (int i = 1; i <= n; i++) {
		printf("%.15Lf", ans[i]);
		cout << endl;
	}
}

Measured memory_bytes: 22912
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    SORT(x)     sort(x.begin(),x.end())
#define    fill(x,y)   memset(x, y, sizeof(x))

using namespace std;

int main(){
	//freopen("in.txt","r", stdin);
	//freopen("out.txt","w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);
	
	set<int> s;
	int n; cin >> n;
	for(int i=0;i<n;i++){
		int a; cin >> a;
		s.insert(a);
	}
	puts(s.size()==n ? "YES" : "NO");
 
	return 0;	
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int L[2 * N];
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L, L + 2 * N);
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2)
    ans += L[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-31T01:23:05+09:00
 */

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) (cont).begin(), (cont).end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

//const double pi=acos(-1.0);
using ll = long long;
//const ll INF = (1LL << 60);
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b; cin >> a >> b;
  cout << a * b << endl;
  
  return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3656