akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>  
#include<random>  
#define int long long  
#define pp pair<int,int>  
#define ss second  
#define ff first  
#define pb push_back  
#define mod 1000000007  
using namespace std;  
void fastio()  
{    
  
  #ifndef ONLINE_JUDGE                  
  freopen("INPUT.txt","r",stdin);              
  freopen("OUTPUT.txt","w",stdout);              
  #endif    
     ios_base :: sync_with_stdio(false);   
     cin.tie(NULL) ;                             
      cout.tie(NULL);                              
   } 
   
signed main()  {    
        fastio();         
         int t=1;           
          // cin>>t;                
           while(t--)                  
              {                        
                string s,t;                          
                cin>>s;
               for(int i=0;i<s.length();i++){
                        if((s[i]=='L'&&i%2==0)||(s[i]=='R'&&i&1))
                        {
                        	cout<<"No";
                        	return 0;
                        }
               }
               cout<<"Yes";
                        
             }   
                    
    }     

Measured memory_bytes: 3612
import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():

    global count
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    adj_list = {}
    edge_list = []
    for i in range(M):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        if a not in adj_list:
            adj_list[a] = [b]
        else:
            adj_list[a].append(b)

        if b not in adj_list:
            adj_list[b] = [a]
        else:
            adj_list[b].append(a)
        edge_list.append((a, b))
    

    count = 0
    for i in range(M):
        (a, b) = edge_list[i]
        is_visit = [False for j in range(N + 1)]
        visit_count = 0
        q = deque([1])
        while 1:
            #print q
            if len(q) <= 0: break;
            
            nd = q.popleft()
            visit_count += 1
            is_visit[nd] = True
            for adj in adj_list[nd]:
                if (nd, adj) != (a, b) and (nd, adj) != (b, a) and is_visit[adj] == False:
                    q.append(adj)
                    is_visit[adj] = True
        if visit_count < N:
            count += 1


    print count



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    way = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a,b,c = map(int,ipt().split())
        way[a].append((b,c))
        way[b].append((a,c))
    q,k = map(int,ipt().split())
    l = [-1]*(n+1)
    l[k] = 0
    Q = queue.Queue()
    Q.put(k)
    while not Q.empty():
        qi = Q.get()
        lq = l[qi]
        for bi,ci in way[qi]:
            if l[bi] == -1:
                l[bi] = lq+ci
                Q.put(bi)

    for i in range(q):
        x,y = map(int,ipt().split())
        print(l[x]+l[y])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 99864
// 問題URL
// https://atcoder.jp/contests/abc150/tasks/abc150_b

import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {

    public static int search(String text, String pattern) {
        int textLen = text.length();
        int patLen = pattern.length();
        int[] skip = new int[Character.MAX_VALUE];

        Arrays.fill(skip, patLen);
        for(int x = 0; x < patLen; x++) {
            skip[pattern.charAt(x)] = patLen - x - 1;
        }

        int i = patLen - 1;
        while (i < textLen) {
            int j = patLen - 1;

            while(text.charAt(i) == pattern.charAt(j)) {
                if (j == 0) return i;
                i--; 
                j--;
            }
            i = i + Math.max(skip[text.charAt(i)], patLen - j);
        }

        return -1;
    }

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        String text = scanner.next();
        String pattern = "ABC";

        int count = 0;
        int result = -1;
        for(;;){
            result = search(text, pattern);
            if (result == -1) break;
            text = text.substring(result + pattern.length());
            count++;
        }

        System.out.println(count);
    }
}


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

using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int main() {
    int N;
    cin >> N;
    while(N--) {
        int dp[1024][1024] = {{}};
        string a,b;
        cin >> a >> b;
        int ans = 0;
        reps(i,1,a.size()+1){
            reps(j,1,b.size()+1) {
                dp[i][j] = max(dp[i-1][j],max(dp[i][j-1], dp[i-1][j-1]+(a[i-1]==b[j-1])));
                ans = max(ans, dp[i][j]);
            }
        }
        cout << dp[a.size()][b.size()] << endl;
    }
    return 0;  
}


Measured memory_bytes: 7256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define MOD 1e9+7
#define ll long long
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
	string s;
	cin>>s;
  	
  	if(s=="ARC") cout<<"ABC"<<endl;
  	else         cout<<"ARC"<<endl;
	return 0;
}


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

#define Ans 1000000007

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

    string s[2];
    cin>>s[0]>>s[1];
    long long int Prod;
    int Flag;

    for(int i=0;i<N;)
    {
        if(i==0)
        {
            if(s[0][0]==s[1][0])
            {
                Prod=3;
                Flag=1;
                i++;
            }
            else
            {
                Prod=6;
                Flag=2;
                i=i+2;
            }

        }
        else
        {
            if(s[0][i]==s[1][i])
            {
                if(Flag==1)
                {
                    Prod=((Prod%Ans)*(2%Ans))%Ans;
                }
                i++;
                Flag=1;
            }
            else
            {
                if(Flag==1)
                {
                    Prod=((Prod%Ans)*(2%Ans))%Ans;
                }
                else
                {
                    Prod=((Prod%Ans)*(3%Ans))%Ans;
                }
                i=i+2;
                Flag=2;
            }
        }
    }

    cout<<Prod<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n, m;
    cin >> n >> m ;

    for(int i = 0; i < m; i++){
        ll a;
        cin >> a;
        n -= a;
    }
    if(n<0){
        cout << -1 << endl;
    }else{
        cout << n << endl;
    }

    return 0;

}


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

namespace AtCoderPanasonicContest2020
{
	class Program
	{
		static void Main(string[] args)
		{
			var number = ReadInt();
			var results = new List<string>
			{
				"a"
			};

			for (var i = 2; i <= number; i++)
			{
				results = results.SelectMany(x => TargetChar(x).Select(y => x + y)).ToList();
			}

			foreach (var str in results)
			{
				Console.WriteLine(str);
			}
		}

		private static string[] TargetChar(string str)
		{
			if (str.IndexOf('b') == -1)
			{
				return new[] { "a", "b" };
			}
			if (str.IndexOf('c') == -1)
			{
				return new[] { "a", "b", "c" };
			}
			if (str.IndexOf('d') == -1)
			{
				return new[] { "a", "b", "c", "d" };
			}
			if (str.IndexOf('e') == -1)
			{
				return new[] { "a", "b", "c", "d", "e" };
			}
			if (str.IndexOf('f') == -1)
			{
				return new[] { "a", "b", "c", "d", "e", "f" };
			}
			if (str.IndexOf('g') == -1)
			{
				return new[] { "a", "b", "c", "d", "e", "f", "g" };
			}
			if (str.IndexOf('h') == -1)
			{
				return new[] { "a", "b", "c", "d", "e", "f", "g", "h" };
			}
			if (str.IndexOf('i') == -1)
			{
				return new[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" };
			}
			return new[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


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

int main(){
    int n;

    while(scanf("%d",&n)==1){
        int upper[n];
        scanf("%d",&upper[0]);

        for(int i=1; i<n; i++){
            int val;
            scanf("%d",&val);
            upper[i] = upper[i-1] + val;
        }

        int lower[n];

        for(int i=0; i<n; i++)
            scanf("%d",&lower[i]);

        for(int i=n-2; i>=0; i--)
            lower[i]+=lower[i+1];

        int mx = INT_MIN;

        for(int i=0; i<n; i++)
            mx = max(mx, upper[i] + lower[i]);

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

    return 0;
}


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

struct Point{
  int64 x1, y1, z1;
  int64 x2, y2, z2;
  Point(){}
  Point(int64 x1, int64 y1, int64 z1, int64 x2, int64 y2, int64 z2):
    x1(x1), y1(y1), z1(z1), x2(x2), y2(y2), z2(z2){};
};


int main(){
  int64 N, K;
  cin >> N >> K;
  vector< int64 > X, Y, Z;
  vector< Point > p(N);
  for(int i = 0; i < N; i++){
    int x1, y1, z1, x2, y2, z2;
    cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
    p[i] = Point( x1, y1, z1, x2, y2, z2);

    X.push_back(x1), X.push_back(x2);
    Y.push_back(y1), Y.push_back(y2);
    Z.push_back(z1), Z.push_back(z2);
  }

  sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end()); Y.erase(unique(Y.begin(), Y.end()), Y.end());
  sort(Z.begin(), Z.end()); Z.erase(unique(Z.begin(), Z.end()), Z.end());


  int64 ret = 0;
  for(int i = 0; i < X.size() - 1; i++){
    for(int j = 0; j < Y.size() - 1; j++){
      for(int k = 0; k < Z.size() - 1; k++){
        int cnt = 0;
        for(int l = 0; l < N; l++){
          if(p[l].x1 <= X[i] && X[i + 1] <= p[l].x2 &&
             p[l].y1 <= Y[j] && Y[j + 1] <= p[l].y2 &&
             p[l].z1 <= Z[k] && Z[k + 1] <= p[l].z2) cnt++;
        }
        if(cnt >= K){
          ret += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (Z[k + 1] - Z[k]);
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,ans=0; cin >> n;
  vector<int> v(n); 
  rep(i,0,n) cin >> v[i];
  rep(i,0,n-2) {
  	if((v[i]<v[i+1] && v[i+1]<v[i+2]) || (v[i]>v[i+1] && v[i+1]>v[i+2])) ans++;
  }
  cout << ans << endl;
 }

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

int A[128];
char B[1001];

int conv(const string &a) {
  int res = 0;
  for(int i = 0; i < a.size(); ++i) {
    int d = 1;
    if(isdigit(a[i])) {
      d = a[i++] - '0';
    }
    res += d * A[a[i]];
  }
  return res;
}

string conv(const int x) {
  string res;
  for(int i = 1000; i >= 1; i /= 10) {
    int d = x / i % 10;
    if(!d) continue;
    if(d > 1) res += (char)(d + '0');
    res += B[i];
  }
  return res;
}

int main() {
  A['m'] = 1000;
  A['c'] = 100;
  A['x'] = 10;
  A['i'] = 1;
  B[1000] = 'm';
  B[100] = 'c';
  B[10] = 'x';
  B[1] = 'i';
  int n; cin >> n;
  while(n--) {
    string a, b;
    cin >> a >> b;
    cout << conv(conv(a) + conv(b)) << endl;
  }
  return 0;
}

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

int main(){
  int A, B;
  string S, T, U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S==U)A--;
  if(T==U)B--;
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int m,n,elem[3] = {2,3,5},tmp;
	int* table = new int[1000001];
	table[0] = 0;
	table[1] = 1;

	for(int i = 2; i <= 1000000; i++){
		tmp = i;
		for(int k = 0; k < 3; k++){
			while(tmp%elem[k] == 0){
				tmp /= elem[k];
			}
		}
		if(tmp == 1){
			table[i] = table[i-1]+1;
		}else{
			table[i] = table[i-1];
		}
	}


	while(true){
		scanf("%d %d",&m,&n);
		if(m == 0)break;

		printf("%d\n",table[n]-table[m-1]);
	}

    return 0;
}

Measured memory_bytes: 6480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
typedef long long LL;
const LL P = 1e9+7;
const int INF = 1e9;
const int N = 220;
const double pi = acos(-1);
mt19937 rng(time(0));

char s[100];
bool ans[N];
int n, a[N];

bool qry1(int l){
	cout<<"? ";
	rep(i,l,l+n-1) cout<<i<<" ";
	cout<<endl<<flush;
	cin>>s;
	return s[0]=='R';
}

bool qry2(int x, int l){
	cout<<"? "<<x<<" ";
	rep(i,l,l+n-2) cout<<i<<" ";
	cout<<endl<<flush;
	cin>>s;
	return s[0]=='R';
}

bool qry3(int x, int l, int r){
	cout<<"? "<<x<<" ";
	rep(i,1,l) cout<<i<<" ";
	rep(i,r,n<<1) cout<<i<<" ";
	cout<<endl<<flush;
	cin>>s;
	return s[0]=='R';
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("test.in","r",stdin);
	#endif
	
	cin>>n;
	bool begin = qry1(1);
	int l = 1, r = n+1;
	while(l+1<r){
		int mid = l+r>>1;
		if(qry1(mid)==begin) l = mid;
		else r = mid;
	}
	//cout<<l<<" "<<r<<endl;
	ans[l] = begin, ans[r+n-1] = !begin;
	
	rep(i,1,l-1) ans[i] = qry2(i,l+1);
	rep(i,r+n,n<<1) ans[i] = qry2(i,l+1);
	
	rep(i,l+1,r+n-2) ans[i] = qry3(i,l-1,r+n);
	
	cout<<"! ";
	rep(i,1,n<<1) cout<<(ans[i]?'R':'B');
	cout<<endl<<flush;
	return 0;
}

Measured memory_bytes: 724
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan. nextInt();
        if(a < b && b < c){
            System.out.println("Yes");
        }
        else {
            System.out.println("No"); 
        }


    }
}


Measured memory_bytes: 26132
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

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

  vector<int> result(n-1);
  Graph G(n);
  for (int i = 0; i < n-1; ++i) {
    result[i] = 0;
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[x].push_back(y);
  G[y].push_back(x);

  
  for (int i = 0; i < n-1; ++i) {
    vector<int> dist(n, -1);
    queue<int> que;
    dist[i] = 0;
    que.push(i);
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (int nv : G[v]) {
        if (dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        if (nv > i) result[dist[v]]++;
        //cout << "i:" << i << " nv:" << nv << " dist:" << dist[nv] << endl;
        que.push(nv);
      }
    }
  }

  for (int i = 0; i < n-1; ++i) {
    cout << result[i] << endl;
  }
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

const int INF = 1001001001;
int mod = 2;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
    int n;
    cin >> n;
    mod = n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    vector<mint> b(n);
    combination c(n - 1);


    rep(i, n) if (a[i]) {
            b[0] += 1;
            mint pw = 1;
            for (int j = n - 1; j >= 0; j--) {
                b[j] -= pw * c(n - 1, j);
                pw *= -i;
            }
        }

    rep(i, n) {
        printf("%11d\n", b[i].x);
    }

}


Measured memory_bytes: 384
import numpy as np

N,M = map(int,input().split())

A = np.array([int(x) for x in input().split()],dtype=np.int64)
A.sort()

BC = np.array([[int(x) for x in input().split()] for _ in range(M)])
B = BC[:,0]
C = BC[:,1]

idx = C.argsort()
B = B[idx][::-1]
C = C[idx][::-1]

p = 0
for b,c in zip(B,C):
  A[p:p+b] = np.maximum(A[p:p+b],c)
  p += b

answer = A.sum()
print(answer)


Measured memory_bytes: 32776
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto H = RDA;
	H.sort!"a > b"();

	long ans;
	foreach (i; K..N)
	{
		ans += H[i];
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 11540
parseline(str=readline()) = parse.(Int, split(str))
function main()
    N, X, M = parseline()
    A = fill(-1, M+1)
    A[1] = X
    e = 0
    flag = zeros(Int, M+1)
    flag[X+1] = 1
    for m in 2:M+1
        temp = powermod(A[m-1], 2, M)
        if flag[temp+1] > 0
            A[m] = temp
            e = m
            break
        end
        flag[temp+1] = 1
        A[m] = temp
    end
    s = findfirst(x->x==A[e], A)
    ans = s>1 ? sum(A[1:s-1]) : 0
    cycle = A[s:e-1]
    per = length(cycle)
    T = (N-s)÷per
    S = mod(N-s, per)
    ans += T*sum(cycle) + sum(cycle[1:S+1])
    println(ans)
end
main()

Measured memory_bytes: 185416
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int card = Integer.parseInt(br.readLine());    //cardに勝負回数を入れる
        String name;
        int t_point=0;
        int h_point=0;
        while ((name=br.readLine())!=null) {
        	if (card>1000 || name.length()>100) break; //cardが1000より大きい場合と、nameの長さが100を超えた場合whileを抜ける
            String[] c_name = name.split(" ");  //splitで空白でnameに入っている文字を区切る
            String tarou = c_name[0];
            String hanako = c_name[1];
            
            int judge = tarou.compareTo(hanako);    //compareToで文字列の大小を比較する
                                                    //compareToは比較した文字列が
                                                    //後になる場合には正数を、等しい場合には0を、前になる場合には負数を返します。
            //勝者が3ポイントプラスで引き分けなら両者に1ポイントプラスします
            if(judge<0){        //if文でjudgeが0より小さい場合には
                h_point += 3;   //花子の方にポイントをプラスします
            }else if(judge>0){  //else ifでjudgeが0より大きい場合には
                t_point += 3;   //太郎の方にポイントをプラスします
            }else{              //elseでjudgeが0の時には
                h_point += 1;   //互いのポイントにプラスします
                t_point += 1;
            }
        }
        System.out.println(t_point+" "+h_point);
    }
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

llong dp[210000][5];

int main (int argc, char *argv[]) {
    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 <bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int ll

const int M=1e9+7;

int mod_pow(int n,int p){
    int ans=1;
    while(p>0){
        if(p%2){
            ans=(ans*n)%M;
        }
        n=(n*n)%M;
        p/=2;
    }
    return ans;
}

void brute(vector<int> &v){
    int ans=0,n=v.size();
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j=i+1;j<n;j++){
            cnt++;
            ans=(ans+(v[i]*v[j])%M)%M;
        }
        assert(cnt==n-i-1);
    }
    deb(ans);
}

void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &x:v)cin>>x;
    // brute(v);
    vector<int> suf(n,0);
    suf[n-1]=v[n-1];
    for(int i=n-2;i>=0;i--)suf[i]=(suf[i+1]+v[i])%M;
    int ans=0;
    for(int i=0;i<n-1;i++){
        // int p=mod_pow(v[i],n-i-1);
        int p=v[i];
        int s=suf[i+1];
        p=(p*s)%M;
        ans=(ans+p)%M;
    }
    cout<<ans<<"\n";
}

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

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

bool dfs(int node, int prenode, vector< vector< int > > &becky, vector<bool> &used){
  bool res = true;
  used[node] = 1;
  for(int i=0; i < (signed int)becky[node].size(); i++){
    if(becky[node][i] != prenode && used[becky[node][i]]){
      return false;
    }
    if(used[becky[node][i]] == false)
      res = dfs(becky[node][i], node, becky, used);
    if(res == false) break;
  }
  return res;
}

int main(void){
  int n, m;
  while(cin >> n >> m, n | m){
    vector< vector< int > > becky(n);
    vector<bool> used(n, 0);
    for(int i=0; i < m; i++){
      int a, b; cin >> a >> b;
      a--; b--;
      becky[a].push_back(b);
      becky[b].push_back(a);
    }

    bool ans = true;
    for(int i=0; i < n; i++){
      if(becky[i].size() >= 3){
	ans = false;
	break;
      }
    }


    for(int i=0; i < n; i++){
      if(ans && used[i] == false){
	ans = dfs(i, -1, becky, used);
      }
    }
    if(ans) cout << "yes" << endl;
    else    cout << "no"  << endl;
  }
  return 0;
}

Measured memory_bytes: 4372
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int c = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] work = new int[n];
        //ArrayList<Integer> work = new ArrayList<Integer>();
        int works = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == 'o'){
                works++;
                work[i] = works;
                if(works == k){
                    break;
                }else{
                    i += c;
                }
            }
        }
        if(works != k) return;
        TreeSet<Integer> ans = new TreeSet<Integer>();
        for(int i = n-1; i >= 0; i--){
            if(s[i] == 'o'){
                if(work[i] == works){
                    ans.add(i+1);
                }
                works--;
                if(works == 0){
                    break;
                }else{
                    i -= c;
                }
            }
        }
        for(int d : ans){
            System.out.println(d);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
    
    public double[] nextDoubleArray(int n) {
        double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = nextDouble();
        return a;
    } 
}


Measured memory_bytes: 57388
L, R = map(int, input().split())
min_mod = 10**9
for i in range(L, min(L + 2019, R + 1)):
    for j in range(i + 1, min(L + 2019, R + 1)):
        min_mod = min(min_mod, (i * j) % 2019)
print(min_mod)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    rep(i, N) {
        ans += (L+i);
    }

    if(L <= 0 && 0 <= L+N-1) {
        cout << ans << endl;
        return 0;
    }
    else if(L+N-1 < 0) {
        ans -= L+N-1;
        cout << ans << endl;
        return 0;
    }
    else if(0 < L) {
        ans -= L;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll a,b,MIN=99999999999;cin>>a>>b;
    if(b-a>0)MIN=min(MIN,b-a);
    if(b+a>=0)MIN=min(MIN,b+a+1);
    if(-b-a>=0)MIN=min(MIN,-b-a+1);
    if(-b+a>0)MIN=min(MIN,-b+a+2);
    cout<<MIN<<endl;
    
}






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

int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    for(int i=0;i<10;i++){
        c=a*c-b;
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  int ns = n;
  int sum = std::accumulate(a.begin(), a.end(), 0);

  size_t res = 0;
  int diff = std::abs(sum - ns*a[0]);
  for (size_t i = 1; i < n; ++i) {
    int cur_diff = std::abs(sum - ns*a[i]);
    if (cur_diff < diff) {
      res = i;
      diff = cur_diff;
    }
  }
  printf("%zu\n", res);
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;

const int Mod = 1e9 + 7;

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

typedef vector <int> Row;
typedef vector <Row> Matrix;

Matrix Zero(int n, int m)
{
    return Matrix(n, Row(m, 0));
}

Matrix Ident(int n)
{
    Matrix Res = Zero(n, n);
    for(int i = 0; i < n; i++)  Res[i][i] = 1;
    return Res;
}

Matrix Multy(const Matrix& A, const Matrix& B)
{
    assert(A[0].size() == B.size());
    Matrix Res = Zero(A.size(), B[0].size());

    for(int i = 0; i < Res.size(); i++)
        for(int j = 0; j < Res[0].size(); j++)
            for(int k = 0; k < B.size(); k++)
                add_self(Res[i][j], mul(A[i][k], B[k][j]));

    return Res;
}

Matrix Power(const Matrix& A, ll k)
{
    if(!k)      return Ident(A.size());
    if(k & 1)   return Multy(A, Power(A, k - 1));
    return Power(Multy(A, A), k / 2);
}

int main()
{

    SPEED;
    ll n,k;
    cin >> n >> k;

    Matrix Graph = Zero(n, n);

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

    Graph = Power(Graph,k);

    int Ans = 0;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            //cout << Graph[i][j] <<" " ;
            Ans += Graph[i][j];
            Ans%=Mod;
        }
       // cout << endl;
    }

    cout << Ans << endl;

    R 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<pair<int, int>> item(N + 1);
    rep(i, 1, N + 1) 
    {
        int w, v;
        cin >> w >> v;
        item[i] = make_pair(w, v);
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, 1, N + 1)
    {
        rep(k, 1, W + 1)
        {
            if (k >= item[i].first) dp[i][k] = dp[i - 1][k - item[i].first] + item[i].second;
            chmax(dp[i][k], dp[i - 1][k]);
        }
    }

    cout  << dp[N][W] << endl;
}


Measured memory_bytes: 80256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <regex>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

	vector<int> N(s.size(), 0);
	for (int i = 0; i < s.size(); i++) {
		N[i] = s[i] - '0';
	}

	vector<int> pre(2019, 0);
	vector<int> next(2019, 0);

	ll sum = 0;
	for (int i = 0; i < N.size(); i++) {
		pre[0] += 1;
		for (int j = 0; j < 2019; j++) {
			next[(j * 10 + N[i]) % 2019] += pre[j];
		}
		sum += next[0];
		swap(next, pre);
		for (int j = 0; j < 2019; j++) {
			next[j] = 0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve(){

  int n,m,a,b,c;
  string str;
  int h, w;
  cin >> h >> w >> a >> b;
  cout << h*w-a*w-b*h +a*b  fin;
  

  

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)

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


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

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    for(int m=0; m<M; m++) {
        cin >> B[m];
    }
    
    int cnt=0;
    for(int n=0; n<N; n++) {
        int sum=0;
        for(int m=0; m<M; m++) {
            int A;
            cin >> A;
            sum += A*B[m];
        }

        if(sum>-C) {
            cnt++;
        }
    }
    
    cout << cnt << endl;


    return 0;
    
}

Measured memory_bytes: 256
n=int(input())
ans=[]
if n==0:
    print(0)
    exit()
    
for i in range(100):
    if  n==0:
        break
    if n%(2**(i+1))==0:
        ans.append('0')
    else:
        if i%2==0:
            n-=2**i
        else:
            n+=2**i
        ans.append('1')
ans.reverse()
print(''.join(map(str, ans)))

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = LLONG_MAX;
constexpr li mod = 1000000007;

void Yes(li b) {
	if (b)cout << "Yes";


	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li N;
	cin >> N;

	vector<int> A(N);

	Input(A);

	vector<int> primeset;

	for (int i = 2; i <= 1000; i++) {
		bool isp = 1;
		for (int j = 2; j * j <= i; j++) {
			if (!(i % j)){isp = 0; break;}
		}
		if (isp) primeset.eb(i);
	}

	int GCD = A[0];
	set<int> foundp;
	bool ispcop = 1;

	for (auto && a : A) {
		GCD = __gcd(GCD, a);

		if (ispcop) {

			for (auto && p : primeset) {
				if(a<p)break;
				if (!(a % p)) {
					if (foundp.count(p)) {
						ispcop = 0;
						break;
					}
					else {foundp.insert(p);}
				}

				while (!(a % p)) {
					a /= p;
				}

			}


			if (a != 1) {
				if (foundp.count(a)) {
					ispcop = 0;
					break;
				}
				else {foundp.insert(a);}
			}

		}


	}


	if (ispcop) {
		cout << "pairwise coprime";
	}
	else if (GCD == 1) {
		cout << "setwise coprime";
	}
	else {
		cout << "not coprime";
	}



}

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

signed main(void)
{
	int n, ans;
	int imos[100010];

	rep(i, 100010) imos[i] = 0;
	cin >> n;
	rep(i, n)
	{
		int a;
		cin >> a;
		if (a != 0)
			imos[a - 1] += 1;
		else
			imos[0] += 1;
		imos[a + 2] += -1;
	}
	rep(i, 100010) imos[i + 1] += imos[i];
	ans = 0;
	rep(i, 100010) ans = max(ans, imos[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,tot;
ll k,two[105],f[105][55][55],dp[55],last[55];
void add(ll &x,ll v)
{
	x+=v;
	if(x>=mod) x-=mod;
}
int main()
{
	scanf("%d%lld",&n,&k);
	ll K=k;
	while(K>0) tot++,K=(K>>1);
	//printf("tot=%d\n",tot);
	two[0]=1;
	for(int i=1;i<=tot;i++) two[i]=two[i-1]*2;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) 
		{
			int x;
			scanf("%d",&x);
			f[0][i][j]=x;
		}
	}
	for(int t=1;t<=tot;t++)
	{
		for(int k=1;k<=n;k++)
		{
			for(int i=1;i<=n;i++)
			{
				for(int j=1;j<=n;j++)
				{
					add(f[t][i][j],f[t-1][i][k]*f[t-1][k][j]%mod);
				}
			}
		}
		/*for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++) printf("f(%d,%d,%d)=%lld\n",t,i,j,f[t][i][j]);
		}*/
	}
	int t=tot;
	for(int i=1;i<=n;i++) last[i]=1;
	while(k>0)
	{
		while(two[t]>k) t--;
		//printf("k=%lld t=%d\n",k,t);
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				add(dp[i],last[j]*f[t][j][i]%mod);
			}
		}
		for(int i=1;i<=n;i++) last[i]=dp[i];
		//for(int i=1;i<=n;i++) printf("last(%d)=%lld\n",i,last[i]);
		k-=two[t];
	}
	ll ans=0;
	for(int i=1;i<=n;i++) add(ans,last[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
#define mod2 20071027
#define mod 1000074259
#define base 139
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define tc(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=500010;
string s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main()
{
    string str;
    cin>>str;
    for(int i=0;i<7;i++)
    {
        if(str==s[i])
        {
            ll m = (7-i)%7;
            if(m<=0)
                m+=7;
            cout<<m<<endl;
            return 0;
        }
    }
    return 0;
}
/*

*/


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

void solve(long long A, string B){
    int intB = 0;
    intB = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0');

    unsigned long long c = intB * A / 100;
    cout << c << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    string B;
    cin >> B;
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;

vector< P > v[100005];

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

    int n, m;
    cin >> n >> m;
    for( int i = 0; i < m; ++i ) {
        int p, y;
        cin >> p >> y;
        v[p].pb( MP( y, i ) );

    }

    vector< P > ans(m);

    for( int i = 1; i <= n; ++i ) {
        sort( v[i].begin(), v[i].end() );
        for( int j = 0; j < v[i].size(); ++j ) {
            ans[v[i][j].S] = MP( i, j + 1 );

        }
    }

    for( int i = 0; i < ans.size(); ++i ) {
        printf( "%06d%06d\n", ans[i].F, ans[i].S );

    }

    return 0;
}



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

int main(void)
{
    int n, m, i, tmp, maxx, miny;
    cin >> n >> m >> maxx >> miny;
    for(i = 0; i < n; i++) {
        cin >> tmp;
        if (maxx < tmp) maxx = tmp;
    }
    for(i = 0; i < m; i++) {
        cin >> tmp;
        if (miny > tmp) miny = tmp;
    }

    if (maxx < miny) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
 
    var a = readLine()!!.toInt()  //500
    var b = readLine()!!.toInt()  //100
    var c = readLine()!!.toInt()  //50
    var x = readLine()!!.toInt()  // target

    var cnt = 0
    for (i in 0..a) {
        for (j in 0..b) {
            for (k in 0..c) {
                val sum = 500*i + 100*j + 50*k
                if (sum == x) {
                    cnt += 1
                }
            }
        }
    }
    print(cnt)
}

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

typedef long long ll;

const long double PI = (acos(-1));

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

  int n, k, q;
  cin >> n >> k >> q;

  vector<int> points(n);
  for (int i = 0; i < n; i++){
    points.at(i) = k;
  }

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

    points.at(a - 1)++;
  }

  for (int i = 0; i < n; i++){
    if (points.at(i) > q){
      cout << "Yes" << endl;
    }else {
      cout << "No" << 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 ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll a[n+1], b[n+1];
	REP(i, n+1){ cin >> a[i]; }
	REP(i, n){ cin >> b[i]; } b[n] = 0;
	ll ans = 0;
	ll tmp = 0;
	REP(i, n+1){
		ans += min(tmp+b[i], a[i]);
		if (tmp+b[i] > a[i]){
			tmp = min(b[i], tmp+b[i]-a[i]);
		}
		else { tmp = 0; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define int long long
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int mod=1e9+7;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
struct node {
	int x,y,z;
}a[1000001];
int val[1000001],pre[1000001],x,y,z,cnt,js,ans;
int find(int x){
	return pre[x]==x?x:pre[x]=find(pre[x]);
}
bool cmp(const node & a , const node & b ){
	return a.z<b.z;
}
main(){
	int n=read(),m=read();
	memset(val,127/3,sizeof(val));
	for(int i=1;i<=m;i++){
		x=read()+1,y=read()+1,z=read(),cnt++;
		a[cnt].x=x,a[cnt].y=y,a[cnt].z=z;
		val[x]=min(val[x],z+1);
		val[y]=min(val[y],z+2);
	}
	for(int i=1;i<=n;i++)
		val[i]=min(val[i],val[i-1]+2);
	val[1]=min(val[1],val[n]+2);
	for(int i=2;i<=n;i++)
		val[i]=min(val[i],val[i-1]+2);
	for(int i=1;i<=n;i++)
		cnt++,a[cnt].x=i,a[cnt].y=i%n+1,a[cnt].z=val[i],pre[i]=i;
	sort(a+1,a+1+cnt,cmp);
	for(int i=1;i<=cnt;i++){
		int fx=find(a[i].x),fy=find(a[i].y);
		if(fx!=fy)
			js++,ans+=a[i].z,pre[fx]=fy;
		if(js==n-1) printf("%lld",ans),exit(0);
	}
}

Measured memory_bytes: 22528
#include<stdio.h>
int main(){
   int n;
   scanf("%d",&n);
   if(n%2!=0){
     printf("No");
     return 0;
   }
int i,o=0;
char s[n+1]; 
scanf("%s",s);

   for(i=0;i<n/2;i++){
       if(s[i]!=s[n/2+i]){
           o++;
       }
   }
   if(o!=0)printf("No");
   else printf("Yes");
    return 0;
}

Measured memory_bytes: 128