akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans
vector<pair<int, int>> prime_factorize(int n) {
    vector<pair<int, int>> ret;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int num = 0;
            while (n % i == 0) {
                num++;
                n /= i;
            }
            ret.push_back({i, num});
        }
    }
    if (n != 1)
        ret.push_back({n, 1});
    return ret;
}
int N;

void solve() {
    auto V = prime_factorize(N);
    int ans = 0;
    for (auto p : V) {
        int n = p.second;
        int tmp = 1;
        while (n - tmp >= 0) {
            ans++;
            n -= tmp;
            tmp++;
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N;

    solve();
    return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class UnionFind(object):
    def __init__(self,n):
        self.__par=list(range(n))
        self.__rank=[0]*n
        self.__size=[1]*n

    def root(self,k):
        if(self.__par[k]==k): return k
        self.__par[k]=self.root(self.__par[k])
        return self.__par[k]

    def unite(self,i,j):
        i=self.root(i); j=self.root(j)
        par=self.__par; rank=self.__rank; size=self.__size
        if(i==j): return False
        if(rank[i]>rank[j]):
            par[j]=i
            size[i]+=size[j]
        else:
            par[i]=j
            size[j]+=size[i]
            if(rank[i]==rank[j]): rank[j]+=1
        return True

    def size(self,k):
        return self.__size[self.root(k)]

def resolve():
    n,m=map(int,input().split())
    uf=UnionFind(n)
    for _ in range(m):
        x,y,z=map(int,input().split())
        x-=1; y-=1
        uf.unite(x,y)
    print(len({uf.root(i) for i in range(n)}))
resolve()

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(auto &e: a) cin >> e, e--;

    vector<ll> imos(m+1), imos2(m+1);
    ll s = 0;
    for(ll i=0; i<n-1; i++) {
        ll t = (m + a[i+1] - a[i]) % m;
        s += t;
        if(t <= 1) continue;

        ll u = (a[i]+2) % m;
        ll v = a[i+1]+1;
        if(u < v) {
            imos[u]++;
            imos[v]--;
            imos2[v]-=v-u;
        } else {
            imos[0]++;
            imos2[0]+=m-u;
            imos[v]--;
            imos2[v]-=v+m-u;
            imos[u]++;
        }
    }
    for(ll i=1; i<m; i++)
        imos[i] += imos[i-1];
    imos[0] += imos2[0];
    for(ll i=1; i<m; i++)
        imos[i] += imos[i-1] + imos2[i];

    ll r = s;
    for(ll i=0; i<m; i++)
        r = min(r, s - imos[i]);

    cout << r << endl;

}


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

vector<long long> h;

long long parent(int n){
  if(n/2 == 0) return numeric_limits<long long>::min();
  return h[n/2];
}

long long left(int n){
  int l = n*2;
  if(l >= h.size()) return numeric_limits<long long>::min();
  return h[l];
}
long long right(int n){
  int r = n*2+1;
  if(r >= h.size()) return numeric_limits<long long>::min();
  return h[r];
}

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

  h.resize(n+1);
  for(int i=1; i<=n; ++i) cin >> h[i];

  for(int i=1; i<=n; ++i){
    cout << "node " << i << ": " << "key = " << h[i] << ", ";
    long long p = parent(i), l = left(i), r = right(i);
    if(p != numeric_limits<long long>::min()) cout << "parent key = " << p << ", ";
    if(l != numeric_limits<long long>::min()) cout << "left key = " << l << ", ";
    if(r != numeric_limits<long long>::min()) cout << "right key = " << r << ", ";
    cout << endl;
  }
}



Measured memory_bytes: 3124
import java.io.BufferedInputStream
import java.io.InputStream
import java.util.StringTokenizer

fun solve(N: Int, A: Int, B: Int, C: Int, l: IntArray) {
    fun calcScore(a: Int, b: Int, c: Int) =
        listOf(A - a, B - b, C - c).sumBy { Math.abs(it) }
    // 0: no use, 1: A, 2: B, 3: C
    val pattern = listOf(0, 1, 2, 3)
    val choices = product(*Array(N) { pattern })
    var ans = 10000000
    for (choice in choices) {
        val aa = choice.mapIndexed { index, value -> if (value == 1) l[index] else 0 }
        val bb = choice.mapIndexed { index, value -> if (value == 2) l[index] else 0 }
        val cc = choice.mapIndexed { index, value -> if (value == 3) l[index] else 0 }
        val asize = aa.count { it != 0 }
        val bsize = bb.count { it != 0 }
        val csize = cc.count { it != 0 }
        if (asize < 1 || bsize < 1 || csize < 1) continue
        ans = Math.min(
            ans,
            calcScore(aa.sum(), bb.sum(), cc.sum()) + (asize + bsize + csize - 3) * 10
        )
    }
    println(ans)
    return
}

fun <T> product(vararg lists: List<T>): List<List<T>> {
    fun <T> oneDimTimesOne(left: List<T>, right: List<T>): List<List<T>> =
            left.flatMap { lelem -> right.map { relem -> listOf(lelem, relem) } }

    fun <T> twoDimTimesOne(left: List<List<T>>, right: List<T>): List<List<T>> {
        val product = mutableListOf<List<T>>()
        for (list in left) {
            for (element in right) {
                product.add(list + listOf(element))
            }
        }
        return product
    }
    require(lists.size >= 2)
    return lists
            .drop(2)
            .fold(oneDimTimesOne(lists[0], lists[1])) { acc, suc -> twoDimTimesOne(acc, suc) }
}
// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val C = sc.next().toInt()
    val l = IntArray(N)
    for (i in 0 until N) {
        l[i] = sc.next().toInt()
    }
    solve(N, A, B, C, l)
}


Measured memory_bytes: 64824
#include<stdio.h>
int f(const int d[30],int s){
  int min=s,c[30],r,z,i,k,l,ny,nx;
  int Y[]={0,1,1,1};
  int X[]={1,1,0,-1};//printf("%d\n",min);
  if(s==0)return 0;
  for(i=0;i<s;i++){
    for(k=0;k<4;k++){
      ny=i/4+Y[k];
      nx=i%4+X[k];
      if(4<ny||nx<0||3<nx||ny*4+nx>=s||d[i]-d[ny*4+nx])continue;
      for(l=z=0;l<s;l++){
	c[l-z]=d[l];
	if(l==i||l==ny*4+nx)z++;
      }//for(l=0;l<s-2;l++)printf("%d ",c[l]);printf("\n");//return 0;
      r=f(c,s-2);
      if(min>r)min=r;
      if(min==0)return 0;
    }
  }
  return min;
}
int main(){
  int n,d[30],i;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<20;i++)scanf("%d",&d[i]);
    printf("%d\n",f(d,20));
  }
  return 0;
}

Measured memory_bytes: 596
def get_root(num):
    if num == root[num]:
        return num
    else:
        root[num] = get_root(root[num])
        return root[num]


def is_same_group(a,b):
    return get_root(a) == get_root(b)


def unite(x,y):
    root_x = get_root(x)
    root_y = get_root(y)

    if root_x == root_y:
        return

    if height[x] > height[y]:

        size[root_x] += size[root_y]
        root[root_y] = root_x 

    elif height[x] < height[y]:

        size[root_y] += size[root_x]
        root[root_x] = root_y

    else:
        size[root_x] += size[root_y]
        root[root_y] = root_x
        height[x] += 1



V,E = map(int,input().split())

root = list(range(V+1))
height = [0]*(V+1)
size = [1]*(V+1)

for i in range(E):
    a, b = map(int, input().split())
    unite(a, b)

print(max(size))

Measured memory_bytes: 20016
//
// Created by sark2 on 16-02-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const ll mod = 1e9 + 7;
const int N = 1e6 + 10;

ll factorial[2*N+10];

ll bin_pow(ll a, ll p){
    ll res = 1ll;
    while(p){
        if(p&1)res=res*a%mod;
        a = a*a%mod;
        p>>=1;
    }
    return res;
}

ll inv(ll x){
    return bin_pow(x, mod-2);
}

ll binom(ll n, ll k){
    n++, k++;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        res = res*(n+k-i+1)%mod;
    }
    for(int i = 1; i <= n; i++){
        res = res*inv(i)%mod;
    }
    return (res-1+mod)%mod;
}

int main() {
    IOS

    int r1, c1, r2, c2;
    cin>>r1>>c1>>r2>>c2;

    ll a = binom(r2,c2);
    ll b = binom(r1-1, c1-1);
    ll c = binom(r1-1, c2);
    ll d = binom(r2, c1-1);



    cout<<(4ll*mod + a + b - c - d)%mod<<endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int no[10][10]={0};
for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
        for(int a=1;a<=n;a++){
                int noofdigit=log10(a);
            if((a%10)==j&&(a/(int)pow(10,noofdigit))==i){
            //cout<<" starting with "<< i <<" and ending with "<<j<<" "<<a<<"no of digits "<<noofdigit<<endl;
                no[i][j]++;
            }
            //if(a==22&&i==2&&j==2){
              //  cout<<a%10<<" "<<a/(int)pow(10,noofdigit)<<endl;
            //}
            //cout<<i<<" "<<j<<" "<<endl;
            //cout<<a<<endl;
        }


    }
}
int sum=0;
for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
            //if(no[i][j]!=0)
           //cout<<"starting with"<< i <<"and ending with"<<j<<no[i][j]<<endl;
      sum+=no[i][j]*no[j][i];
    }
    //cout<<endl;
}
cout<<sum;
return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<map>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define N 15
#define MAX 1000
string H[N] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};

int G[N][N], n, V[MAX];
map<string, int> M;

void init(){
    rep(i, N) rep(j, N) G[i][j] = 0;
    rep(i, N){
	for( int j = 1; j <= 7; j++ ){
	    G[i][(i+j)%N] = 1;
	}
    }
    rep(i, N) M[H[i]] = i;
}

void simulate(){
    rep(i, n){
	int win = 0, lose = 0;
	rep(j, n){
	    if ( i == j ) continue;
	    if ( G[V[i]][V[j]] ) win++;
	    if ( G[V[j]][V[i]] ) lose++;
	}
	if ( win > 0 && lose == 0 ) {
	    cout << H[V[i]] << endl;
	    return;
	}
    }
    cout << "Draw" << endl;
}

main(){
    init();
    string name;
    while( cin >> n && n ){
	rep(i, n){
	    cin >> name; V[i] = M[name];
	}
	simulate();
    }
}

Measured memory_bytes: 924
n = int(input())
cnt = 0
ch = 0
*w, = map(str,input().split())
#print(w)
for i in w:
  for j in i:
    #print(j)
    if j == 'I':
      cnt+=1
    elif j == 'D':
      cnt-=1
    if cnt > ch:
      ch = cnt
print(ch)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	
	char[] target;
	int cnt=0;
	
	void check(char[] o){
		int space, work;
		boolean flag;
		
		for(int j=0; j<o.length; j++){
			flag=true;
			if(target[0]==o[j]){//??????????????????????????£??????
				
				for(int k=j+1; k<o.length; k++){
					if(target[1]==o[k]){//??????????????????????????£??????
						
						space = k-j;
						if(o.length<=space*(target.length-1)+j) break;//??????????????\???????????¨????????£??????
						work = k;
						
						for(int l=2; l<target.length; l++){
							work+=space;
							if(o[work]!=target[l]) break;//??????????????\???????????£??????
							if(l==target.length-1){
								cnt++;
								flag = false;//???????????£???????????§?¬?????????????
							}
						}
						if(flag==false) break;
					}
				}
			}
			if(flag==false) break;
		}
	}
	
	void doIt(){
		Main m = new Main();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		m.target = sc.next().toCharArray();
		char[] old;
		
		for(int i=0; i<n; i++){
			old = sc.next().toCharArray();
			m.check(old);
		}
		
		System.out.println(m.cnt);
	}
	
	public static void main(String[] args){
		new Main().doIt();
	}
	
}

Measured memory_bytes: 27532
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100001];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    sort(a,a+n);
    int s=a[n-1]/2,t=0;
    int d=1e9+5;
    for(int i=n-2;i>=0;i--){
        if(abs(s-a[i])<d){
            d=abs(s-a[i]);
            t=i;
        }
    }
    printf("%d %d\n",a[n-1],a[t]);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>

#define INF (1<<30)
using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    int a[n];
    int h[n];
    for (int i = 0; i < n; i++)cin >> h[i];
    for (int i = 1; i < n; i++)a[i] = INF;
    a[0]=0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k && j + i < n; j++) {
            a[i + j] = min(a[i + j], abs(h[i] - h[i + j]) + a[i]);
        }
    }
    cout << a[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
n,m,x=map(int,input().split())
l=[0for i in range(n+1)]
for i in map(int,input().split()):
  l[i]=1
for i in range(1,n+1):
  l[i]+=l[i-1]
print(min(l[x],l[n]-l[x]))
    

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

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

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

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


signed main(){
  int N, H, W, x,temp[30000] = {}, count = 0;

  cin>>N>>H>>W;

  for(int i = 0; i < N; i++){
    cin>>x;
    if(i%2==1)x *= -1;
    for(int j = 1; j <= W ;j++){
      temp[W*i+x+j] = 1;
    }
  }

  for(int i = 1; i <= W*N; i++){
    if(temp[i]== false)count++;
    // cout<<i<<" "<<temp[i]<<endl;
  }

  cout<<count*H<<endl;

  return 0;
}



Measured memory_bytes: 3368
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)

ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k] and l[i]+l[j]>l[k]:
        ans+=1
print(ans)
  

Measured memory_bytes: 9128
t = list(input())
n = int(input())
for i in range(n):
    s = input().split()
    if s[0] == "print":
        print("".join(t[int(s[1]):int(s[2])+1]))
    elif s[0] == "reverse":
        for j in range(((int(s[2])-int(s[1]))//2)+((int(s[2])-int(s[1]))%2)):
             temp = t[int(s[1])+j]
             t[int(s[1])+j] = t[int(s[2])-j]
             t[int(s[2])-j] = temp
    elif s[0] == "replace":
        for k in range(len(s[3])):
            t[int(s[1])+k] = s[3][k]


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

int main() {
    int N;
    cin >> N;
    vector<int> stair(N);
    for(int i=0; i<N;i++){
        cin >> stair.at(i);
    }
    string ans = "Yes";
    for(int i=1;i<N;i++){
        if (stair.at(i-1) <= stair.at(i)-1){
            stair.at(i) -=1;
        }
        else if (stair.at(i-1) != stair.at(i)){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
int t,n,m,k,x,y,w;
signed main(){
	fastio;
	string s;
	cin>>s;
	int rem=15-s.size();
	forstl(it,s){
		if(it=='o') rem++;
	}
	if(rem>=8) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long int mul=1,a[100010];
    int n,zero=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]==0)
            zero++;
    }
    if(zero>0)
    {
        mul=0;
        goto tt;
    }
    else
    {
        for(i=0;i<n;i++)
        {
            if(a[i]<=1000000000000000000/mul)
            {
                mul=mul*a[i];
            }
            else
            {
                mul=-1;
            }
        }
    }
    tt:
    printf("%lld\n",mul);
    return 0;
}


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

#define debug(x) cout << #x << ": " << (x) << endl
#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline void File() {
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
}

const int N = 5e3 + 10, mod = 1e9 + 7;
char s[N]; int n, len, dp[N][N];

inline int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }

inline int qpow(int a, int b) {
	static int res;
	for (res = 1; b; b >>= 1, a = 1ll * a * a % mod)
		if (b & 1) res = 1ll * res * a % mod;
	return res;
}

int main() {

	cin >> n, scanf("%s", s + 1), len = strlen(s + 1);

	dp[0][0] = 1;
	For(i, 0, n) For(j, 0, i) {
		dp[i + 1][j + 1] = add(dp[i + 1][j + 1], 2ll * dp[i][j] % mod);
		dp[i + 1][max(j - 1, 0)] = add(dp[i + 1][max(j - 1, 0)], dp[i][j]);
	}

	int ans = 1ll * dp[n][len] * qpow(qpow(2, len), mod - 2) % mod;

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


Measured memory_bytes: 96512
n, y = map(int,input().split())
y = y / 1000
f = 0
for i in range(n+1):
    for j in range(n-i+1):
        #print(i)
        if 10 * i + 5 * j + 1 * (n - i - j) == y:
            print(i)
            print(j)
            print(n - i - j)
            f = 1
            break
    if f == 1:
        break
if f != 1:
    print(-1)
    print(-1)
    print(-1)

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

int main()
{
  int N; cin >> N;
  int ans = 0, now, num = 0;
  cin >> now;

  for (int i = 0; i < N - 1; i++)
  {
    int next; cin >> next;
    if (now >= next) num++;
    else {
      ans = max(ans, num);
      num = 0;
    }
    now = next;
  }
  ans = max(ans, num);
  cout << ans << endl;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, x, k;
    cin>>n;
    vector<ll>a(n);
    ll res = 0, mn = LLMX;
    for(ll i=0;i<n;i++) cin>>a[i];
    sort(all(a));
    unordered_set<ll>s;
    for(ll i=0;i<n;i++)
    {
        x = sqrt(a[i]);
        bool f = true;
        if(upper_bound(all(a), a[i]) - lower_bound(all(a), a[i]) > 1)
            f = false;
        for(ll j=1;f && j<=x;j++)
        {
            if(a[i]%j == 0)
            {
                k = a[i]/j;
                if(s.find(j) != s.end() || s.find(k) != s.end())
                {
                    f = false;
                    break;
                }
            }
        }
        s.insert(a[i]);
        if(f)
            res++;
    }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 12996
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    if(a==111){
        cout<<"999"<<endl;
    }
    else if(a==999){
        cout<<"111"<<endl;
    }
    else if(a==119){
        cout<<"991"<<endl;
    }
    else if(a==191){
        cout<<"919"<<endl;
    }
    else if(a==911){
        cout<<"199"<<endl;
    }
    else if(a==199){
        cout<<"911"<<endl;
    }
    else if(a==991){
        cout<<"119"<<endl;
    }
    else if(a==919){
        cout<<"191"<<endl;
    }
    else if(a==199){
        cout<<"199"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;
  int ans=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(ans*2>=ans+k){
      ans=ans+k;
    }else{
      ans=ans*2;
    }
  }
  cout<<ans<<"\n";
  return 0;
}


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

int main() {
  int X;
  cin >> X;
  int i = 0;
  int result;
  while (true) {
    bool flag = true;
  	result = X + i;
    if (result == 1 || result == 2) {break;}
    if (result / 2 > 0 && result % 2 == 0) {
     // 偶数
      flag = false;
    } else {
      for(int j = 3; j < result; j+=2) {
      	if (result / j > 0 && result % j == 0) {
        	flag = false;
        }
      }
    }
    if (flag) {
    	break;
    } else {
    	i++;
    }
  }
  cout << result << endl;
  
}


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

int main() {
    long long N; cin >> N;
    long long A, B, C, D; cin >> A >> B >> C >> D;
    for (int i = 0; i < N; i++) {
        if (C * (N - 1 - i) - D * i <= B - A && B - A <= D * (N - 1 - i) - C * i) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, INF))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, INF))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  while(1){
    int n, m;
    cin >> n >> m;
    if(n==0){break;}
    arr(c,m);
    arr(x,n);

    ll INF = 1e18;
    vecll2(dp, 20001, 256);

    dp[0][128]=0;

    rep(i,n){
      rep(j,256){
        if(dp[i][j]==INF) continue;
        rep(k,m){
          int yn = j + c[k];
          if(yn>255) yn=255;
          if(yn<0) yn=0;
          int tmp=(x[i]-yn)*(x[i]-yn);
          chmin(dp[i+1][yn], dp[i][j]+tmp);
        }
      }
    }

    ll ans=INF;
    rep(i,256){
      chmin(ans, dp[n][i]);
    }
    prt(ans);
  }
}



Measured memory_bytes: 43756
// Aizu Vol-3 0336: Sunrise and Sunset
// 2017.8.25

#include <stdio.h>

int main()
{
	int H, R;
	scanf("%d%d", &H, &R);
	if (H == -R) puts("0");
	else if (H > -R) puts("1");
	else puts("-1");
	return 0;
}

Measured memory_bytes: 580
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var S = Console.ReadLine();
        var N = long.Parse(Console.ReadLine());
        var ans = new List<long>();
        if(N < 27)
        {
            N--;
            ans.Add(N);
        }
        else
        {
            
            while(N != 0)
            {
                N--;
                ans.Add(N % 26);
                N /= 26;
            }
        }

        var name = "";
        for (int i = ans.Count - 1; i >= 0; i--)
        {
            var num = (char)(((int)'a') + ans[i]);

            name += num;
        }

        Console.WriteLine(name);
    }



}


Measured memory_bytes: 27804
import scala.io.StdIn._
object Main extends App {

  val n: Int = readInt()
  val pointSeq: Seq[(Int, Int)] = Seq.fill(n)(readLine().split(" ").map(_.toInt))
    .map(arr => (arr(0), arr(1)))

  def solve() = {
    val combinations = pointSeq.combinations(2).toSeq
    val totalDistance = combinations.foldLeft(0D) { case (acc, points) =>
      acc + distance(points(0), points(1))
    }
    totalDistance * 2 / n
  }

  def distance(point1: (Int, Int), point2: (Int, Int)): Double = {
    val (x1, y1) = point1
    val (x2, y2) = point2
    Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2))
  }

  println(solve())

}


Measured memory_bytes: 25424
#include<bits/stdc++.h>//并查集 
using namespace std;
const int maxn = 1e5+5;
int pa[maxn];
int f(int x) {
    return x == pa[x] ? x : (pa[x] = f(pa[x]));
}
void un(int x, int y) {
    int px = f(x);
    int py = f(y);
    if (px != py) {
        pa[px] = py;
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> nums(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> nums[i];
    }
    for (int i = 0; i < maxn; i++) {
        pa[i] = i;
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        un(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (f(nums[i]) == f(i)) {
        	//cout<<nums[i]<<" "<<i<<endl;
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
} 

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

const MaxBuf = 200100
var buf []byte = make([]byte,MaxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf,MaxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r,_ := strconv.Atoi(sc.Text())
	return r
}

func readInt64() int64 {
	sc.Scan()
	r,_ := strconv.ParseInt(sc.Text(),10,64)
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r,_ := strconv.ParseFloat(sc.Text(),64)
	return r
}

func main() {
	a := readInt()
	b := readInt()
	c := readInt()
	ans := 0
	for i := a; i <= b; i++ {
		if c % i == 0 {
			ans++
		}
	}
	fmt.Println(ans)

}


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

int main()
{
    int n;
    cin >> n;
    int a[100005];
    for(int i = 1; i <= n; i++) cin >> a[i];
    a[n + 1] = 0;
    sort(a + 1, a + n + 1, greater<int>());
    int f = 0, s = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] > a[i + 1]){
            if((i + a[i]) % 2) f = max(f, min(i, a[i]));
            else s = max(s, min(i, a[i]));
        }
    }
    if(f >= s) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 640
from collections import deque
#わからない、テストケース
n=int(input())
#それぞれ長さはn-1
a=[[j-1+n*i if j-1<i else i+n*(j-1) for j in list(map(int,input().split()))] for i in range(n)]
#試合の候補をいれる
d=dict()
for i in range(n):
    if a[i][0] in d:
        d[a[i][0]]+=1
    else:
        d[a[i][0]]=1
#どこまで見たか
b=[0]*n
#最大n(n-1)/2回
ans=0
nextd=deque()
cleard=deque()
changeable1=deque(set([a[i][0] for i in range(n)]))
while len(d):
    ans+=1
    #一個も同じのなかったらむり
    g=True
    changeable2=deque()
    for i in changeable1:
        if d[i]==2:
            g=False
            e,f=i//n,i%n
            cleard.append(i)
            b[e]+=1
            b[f]+=1
            if b[e]<n-1:
                nextd.append(a[e][b[e]])
                changeable2.append(a[e][b[e]])
            if b[f]<n-1:
                nextd.append(a[f][b[f]])
                changeable2.append(a[f][b[f]])
    if g:
        exit(print(-1))
    ln,lc=len(nextd),len(cleard)  
    for _ in range(ln):
        i=nextd.popleft()
        if i in d:
            d[i]+=1
        else:
            d[i]=1
    for _ in range(lc):
        i=cleard.popleft()
        #print(i)
        #print(d)
        d.pop(i)
    changeable1=set(changeable2)
print(ans)

Measured memory_bytes: 98512
#include <iostream>
 
using namespace std;
 
int main(void){
  int state; //ツ前ツ嘉アツづ個督ョツつ「ツつスツ陛サツ古シ
  int x, y; //current position
  bool horizon[5][4];
  bool vertical[4][5];
  char tmp;
  int i,j;
 
  for(i=0;i<9;i++){
	if(i%2 == 0){
	  for(j=0;j<4;j++){
		cin >> tmp;
		if(tmp == '1'){
		  horizon[i/2][j] = true;
		}else{
		  horizon[i/2][j] = false;
		}
	  }
	}else{
	  for(j=0;j<5;j++){
		cin >> tmp;
		if(tmp == '1'){
		  vertical[i/2][j] = true;
		}else{
		  vertical[i/2][j] = false;
		}
	  }
	}
  }
 
  state = 'R';
  cout << "R";
  x = 0;
  y = 1;
 
  while(!(x == 0 && y == 0)){
	if(state == 'R'){
	  if(x - 1 >= 0 && vertical[x-1][y] ){
		state = 'U';
		x--;
		cout << "U";
	  }else if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else{
		state = 'L';
		y--;
		cout << "L";
	  }
	}else if(state == 'D'){
	  if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else if( y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else{
		state = 'U';
		x--;
		cout << "U";
	  }
	}else if(state == 'L'){
	  if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else if(x >= 1 && vertical[x-1][y]){
		state = 'U';
		x--;
		cout << "U";
	  }else{
		state = 'R';
		y++;
		cout << "R";
	  }
	}else{
	  if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else if(x >= 1 && vertical[x-1][y]){
		state = 'U';
		x--;
		cout << "U";
	  }else if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else{
		state = 'D';
		x++;
		cout << "D";
	  }
	}
	//cout << x << " " << y << endl;
	//cin >> i;
  }
  cout << endl;
  return 0;
}
 

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

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int arr[3];
    for(int i = 0; i < 3; ++i) {
        cin >> arr[i];
    }
    sort(arr, arr + 3);
    int ans = 0;
    for(int i = 0; i < 2; ++i) {
        ans += (arr[i + 1] - arr[i]);
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    string str[3];
    cin >> str[0] >> str[1] >> str[2];
    cout << str[0][0] << str[1][1] << str[2][2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long int A[500000];

int n;
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}
void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int large;
    if(l<=n&&A[l]>A[i]){
        large = l;
    }else{ 
        large = i;
    }    
    if(r<=n&&A[r]>A[large]){
        large = r;
    }
    if(large!=i){
        swap(A[i],A[large]);
        maxHeapify(large);
    }
}

void buildMaxHeap(){
    for(int i=n/2;i>0;i--)
        maxHeapify(i);
}

int main(){
    cin>>n;
    A[0]=0;
    for(int i=1;i<=n;i++)
	cin>>A[i];
    buildMaxHeap();
    for(int i=1;i<n;i++)
	cout<<" "<<A[i];
    cout<<" "<<A[n]<<"\n";
    return 0;
}

Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
#define l1 long long 
const long double PI = acos(-1.0);
int main(){int k; cin >> k; string str; cin>> str;
 if(str.length()<=k)cout<<str;
 else{
 	for(int i=0;i<k;i++)cout<<str[i];
 	cout<<"...";
 }
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <string.h>
using namespace std;
// std::ios::sync_with_stdio(false);
typedef long long LL;
const int N = 150000;
const int M = 12;
const int INF = 0x3f3f3f3f;
const LL MOD = 1e9+7;
const double Pi = acos(-1);
int n,m;
char s[N];
int main()
{
    while (~scanf("%s",&s))
    {
        int l = strlen(s);
        int f = 0;
        for (int i=0;i<l-1;i++)
        {
            if (s[i]=='A' && s[i+1]=='C')
            {
                f=1;
                break;
            }
        }
        if (f)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

/*


*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll mod = 998244353;
const ll maxn = 1e17;


bool vis[101][101];

bool in(ll x, ll y, ll r, ll c){
  return x>=0 && y >= 0 && x < r && y<c;
}

void solve(){
 
  ll n, i, j, k;

  cin>>n;

  ll a[n];
   ll xo = 0;

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

  for(i = 0;i < n;i++){
    cout<<(xo^a[i])<<" ";
  }

 


}   


int main(){

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

    ll t = 1;
    
   // cin>>t;

    while(t--){
        solve();
    }
   
}




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

using namespace std;

const int maxn = 1010, mod = 1e9 + 7;
int a[maxn][maxn], dp[maxn][maxn], n, m;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            char c;
            cin >> c;

            a[i][j] = c == '.';
        }

    dp[1][1] = 1, a[1][1] = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (a[i][j])
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;

    cout << dp[n][m];

    return 0;
}


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

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  cin.ignore();
  int mata[n][m];
  int matb[m][l];
  long matc[n][l];
  long int sum;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> mata[i][j];
    }
    cin.ignore();
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin >> matb[i][j];
    }
    cin.ignore();
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      sum = 0;
      for(int k=0;k<m;k++){
        sum += mata[i][k]*matb[k][j];
      }
      matc[i][j] = sum;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j !=(l-1)){
        cout << matc[i][j] <<  " ";
      }else{
	cout << matc[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

ll H,N;
int main(){
    cin>>H>>N;
    VL A(N);
    ll cnt=0;
    ll i=0;
    while(H>0){
        cin>>A[i];
        H-=A[i];
        cnt++;
        i++;
        if(i==N)break;
    }
    if(i==N&&H>0)cout<<"No";
    else cout<<"Yes";

    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

ll dp[3010][3010] = {};

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

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

    for (int i = 0; i <= N; ++i) {
        for (int j = i; j <= N; ++j) {
            bool f_Taro = ((N - (j - i)) & 1) == 1;
            if (f_Taro) {
                dp[i][j] = L_INF;
            }
            else {
                dp[i][j] = -L_INF;
            }
        }
    }

    for (int i = 0; i <= N; ++i) {
        dp[i][i] = 0;
    }
    for (int len = 0; len < N; ++len) {
        for (int l = 0; l <= N - len; ++l) {
            int r = l + len;
            bool f_Taro = ((N - (r - l)) & 1) == 1;

            int nl, nr;
            if (f_Taro) {
                nl = l - 1;
                nr = r;
                if (nl >= 0) {
                    dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nl]);
                }

                nl = l;
                nr = r + 1;
                if (nr <= N) {
                    dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nr - 1]);
                }
            }
            else {
                nl = l - 1;
                nr = r;
                if (nl >= 0) {
                    dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nl]);
                }

                nl = l;
                nr = r + 1;
                if (nr <= N) {
                    dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nr - 1]);
                }
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}


Measured memory_bytes: 70144
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,a,b,v[55],c[55][55],ans2;
double sum,ans;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	for(ll i=1;i<=n;i++) c[i][0]=c[i][i]=1;
	for(ll i=2;i<=n;i++) for(ll j=1;j<i;j++) c[i][j]=c[i-1][j-1]+c[i-1][j];
	for(ll i=0;i<n;i++) scanf("%lld",&v[i]);
	sort(v,v+n,greater<ll>());
	for(ll i=0;i<a;i++) sum+=v[i];
	ans=sum/a;
	printf("%lf\n",ans);
	int all=0,x=0,y=0;
	for(ll i=0;i<n;i++) if(v[i]==v[a-1]) all++;
	for(ll i=0;i<a;i++) if(v[i]==v[a-1]) x++;
	for(ll i=0;i<b;i++) if(v[i]==v[a-1]) y++;
	if(v[a-1]!=v[0]) ans2=c[all][x];
	else for(ll i=x;i<=y;i++) ans2+=c[all][i];
	printf("%lld\n",ans2);
	return 0;
}

Measured memory_bytes: 256
X=int(input())

def func(i):
    global n
    global hoge
    n-=int(hoge/i)
    hoge=hoge%i

n=int(X/100)
hoge=X%100

for i in [5,4,3,2,1]:
    func(i)
if n<0:
    print(0)
else:
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int N = 365;
constexpr int INF = 1 << 30;

bool solve() {
    int m;
    std::cin >> m;
    if (m == 0) return false;

    std::vector<std::tuple<int, int, int>> ts(m);
    for (auto& t : ts) {
        int l, r, c;
        std::cin >> l >> r >> c;
        t = std::make_tuple(--l, r, c);
    }
    std::sort(ts.begin(), ts.end());

    auto dp = vec(N + 1, vec(N + 1, 0));

    for (auto t : ts) {
        int l, r, c;
        std::tie(l, r, c) = t;

        for (int i = N; i >= 0; --i) {
            dp[i][r] = std::max(dp[i][r], dp[i][l] + c);
            dp[r][i] = std::max(dp[r][i], dp[l][i] + c);
        }

        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= N; ++j) {
                if (i + 1 <= N) dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
                if (j + 1 <= N) dp[i][j + 1] = std::max(dp[i][j + 1], dp[i][j]);
            }
        }
    }

    std::cout << dp[N][N] << "\n";

    return true;
}

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

    while (solve()) {}

    return 0;
}



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

long long dp[110][10010];
long long inf = 10e10;
long long N,W;
int main(){
	cin >> N >> W;
	long long v[N+1] = {0},w[N+1] = {0};
	for(int i=0;i<N;i++){
		cin >> v[i] >> w[i];
	}
	fill(dp[0],dp[0] + 10010,inf);
	dp[0][0] = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=10000;j++){
			if(j < v[i]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = min(dp[i][j] , dp[i][j-v[i]] + w[i]);
		}
	}
	int ans = 0;
	for(int i=0;i<=10000;i++){
		if(dp[N][i] <= W) ans = i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11008
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

int MOD=1000000007;

int main()
{
  int c[3][3],a[3]={},b[3]={};
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  for(int i=0; i<3; i++) b[i]=c[0][i]-a[0];
  for(int i=1; i<3; i++) a[i]=c[i][0]-b[0];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(c[i][j]!=a[i]+b[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 256
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
ans = 0
e = 0
for i in range(a[0]):
  d = list(map(int,input().split()))
  c .append(d)
for i in c:
  for j in range(a[1]):
    e += b[j]*i[j]
    
  if e + a[2] > 0:
    ans += 1
  e = 0
print(ans)
  



Measured memory_bytes: 9200
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
sum_A = np.sum(A)
res = np.cumsum(A)
value = getNearestValue(res, sum_A/2)
print(abs(value - (sum_A - value)))

Measured memory_bytes: 34192
from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False

    return True

if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)

else:
    print(n * (n - 1) // 2 - m)

Measured memory_bytes: 35696