akhauriyash/Code-Regression huggingface dataset:
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
a=array(N,0)
K.times do|i|
    d=gets.to_i
    b=nil
        b=get_i
    d.times do|j|
        a[b[j]-1]+=1
    end
end
puts a.count{|x| x.zero?}

Measured memory_bytes: 14424
import numpy as np

ans = 0

N=int(input())
A=list(map(int,input().split()))
npA=np.array(A)

counts = [0] * (10**5 + 1)

for a in npA:
	counts[a]+=1

ans = np.sum(npA)

Q=int(input())

for q in range(Q):
	diff = 0
	B,C = map(int,input().split())

	if 0 < counts[B]:
		diff = ( C - B ) * counts[B]
		counts[C] += counts[B]
		counts[B] = 0

	ans += diff
	print(ans)



Measured memory_bytes: 38928
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    
    if(A>=K){
        cout << K << endl;
    }else if(A+B>=K){
        cout << A << endl;
    }else{
        cout << A-(K-A-B) << endl;
    }
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		ArrayList<Pair> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Pair(i + 1, sc.nextInt()));
		}
		list.sort(new ComparatorByValue());
		for (int i = 0; i < n; i++) {
			System.out.print(list.get(i).key + " ");
		}
		System.out.println();
	}
}

class Pair {
	public int key;
	public long value;
	public Pair(int key, long value) {
		this.key = key;
		this.value = value;
	}
}

class ComparatorByValue implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.value == sort2.value) {
			return 0;
		} else if (sort1.value > sort2.value) {
			return 1;
		} else {
			return -1;
		}
	}
}

class ComparatorByKey implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.key == sort2.key) {
			return 0;
		} else if (sort1.key > sort2.key) {
			return 1;
		} else {
			return -1;
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 45808
import bisect

N = int(input())
numbers = [int(i) for i in input().split()]
numbers = sorted(numbers)
counter = 0

for a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(numbers, numbers[a] + numbers[b])
        if c > b:
            counter += c - b -1
        
print(counter)

Measured memory_bytes: 9216
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		string S = Console.ReadLine();

		bool isCorrect = (S[A] == '-');
		for(int i = 0; i < A + B + 1; i++)
		{
			if(i == A)
				continue;
			else if((S[i] < '0') || (S[i] > '9'))
			{
				isCorrect = false;
				break;
			}
		}

		Console.WriteLine(isCorrect ? "Yes" : "No");
	}
}





Measured memory_bytes: 13140
using System;
using System.Text;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<List<int>> resultList = new List<List<int>>();

            string input;
            while (true)
            {
                input = Console.ReadLine();

                if (input == "0 0")
                {
                    break;
                }

                string[] inputArray = input.Split(' ');
                int start = int.Parse(inputArray[0]);
                int end = int.Parse(inputArray[1]);

                List<int> leapYear = new List<int>();

                for (int i = start; i <= end; i++)
                {
                    if (DateTime.IsLeapYear(i))
                    {
                        leapYear.Add(i);
                    }
                }

                resultList.Add(leapYear);

            }


            int count = 0;
            foreach (List<int> l in resultList)
            {
                if (l.Count == 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    foreach (int a in l)
                    {
                        Console.WriteLine(a);
                    }
                }

                if (count != resultList.Count - 1)
                {
                    Console.WriteLine();
                }
                count++;
            }

        }


    }
}

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

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



Measured memory_bytes: 3532
#include<stdio.h>

int main(void)
{
	int n,i,a[10000],max,min;
	long sum = 0;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
                scanf("%d",&a[i]);
		sum += a[i];
	}
	min = a[0];
	max = a[0];
	for(i = 0;i < n;i++){
		if(min > a[i]){
			min = a[i];
		}else if(max < a[i]){
			max = a[i];
		}
	}
	printf("%d %d %ld\n",min, max, sum);
	return 0;
}

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

int main(){
    int N, K;
    int x = 1;

    cin >> N >> K;
    
    for(int i = 0; i < N; i++){
        if(x * 2 >= x + K){
            x += K;
        }else{
            x *= 2;
        }
    }
    
    cout << x << endl;
    
}

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

using namespace std;

int main(void){
	string s;
	cin >> s;
	int a, b, c;
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int main()
{
	int n, m;
	while(cin >> n >> m && (n || m))
	{
		vint flag(n, 1);

		int index = 0;
		rep(i, n - 1)
		{
			for(int p = 0; ; ++index %= n)
			{
				if(flag[index])
					p++;
				if(p == m)
					break;
			}

			flag[index] = 0;
		}

		rep(i, n)
			if(flag[i])
				cout << i + 1 << endl;
	}
}

Measured memory_bytes: 908
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    string s;
    cin >> s;
    if (s.size() == 2)cout << s << endl;
    else {
        reverse(all(s));
        cout << s << endl;
    }
}

Measured memory_bytes: 256
S=input()
ans=0
if S=="MON":
  ans=6
elif S=="TUE":
  ans=5
elif S=="WED":
  ans=4
elif S=="THU":
  ans=3
elif S=="FRI":
  ans=2
elif S=="SAT":
  ans=1
else:
  ans=7
print(ans)

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

int main(){
  int64_t N,K;
  cin>>N>>K;
  set<int64_t> x;
  for(;!x.count(N);){
    x.insert(N);
    if(N>K)
      N%=K;
    else
      N=K-N;
  }
  cout<<*begin(x)<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int d,t,s;
  cin >> d >> t >> s;
  if((d+s-1)/s>t){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
import heapq

m = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(len(a)):
  a[i] = a[i]*-1

heapq.heapify(a)

for i in range(m[1]):
     k= heapq.heappop(a)
     heapq.heappush(a, -(-k//2))

print(sum(a)*-1)

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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;

    return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {

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

    int ans = 0;
    while (n > 0) {
        n /= k;
        ans++;


    }
    cout << ans << endl;

}

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

using namespace std;

int main() {
  int n, m;
  string s;
  while (true) {
    int p = 0;
    long long total = 0;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    cin >> m >> s;
    while (p < m) {
      if (s[p] == 'I') {
        int count = 0;
        while (s.substr(p + 2 * count + 1, 2) == "OI") {
          ++count;
        }
        total += max(0, count - n + 1);
        p += 1 + 2 * count;
      } else {
        ++p;
      }
    }
    cout << total << endl;
  }
}

Measured memory_bytes: 2120
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (500006)
ll n,dp[MAXN],pre[MAXN],nxt[MAXN];
string A;
int main(){
	FAST
	cin>>n>>A;
	// 111111101 call from front
	// 101111111 call from back
	ll tmp=-1;
	FOR(i,0,n-1){
		if(A[i]=='0')tmp=i;
		pre[i]=tmp;
	}
	tmp=n;
	DEC(i,n-1,0){
		if(A[i]=='0')tmp=i;
		nxt[i]=tmp;
	}
	FOR(i,0,n-1){
		if(i) dp[i]=max(dp[i], dp[i-1]);
		if(A[i] == '0') continue;
		if(pre[i] > 0 && A[pre[i]-1]=='1') {
			dp[i]=max(dp[i], (pre[i] - 2 < 0 ?  0 : dp[pre[i]-2]) + i - pre[i]);
		}
		if(nxt[i] < n-1 && A[nxt[i]+1] == '1'){//update with i-1
			dp[nxt[i]+1]=max(dp[nxt[i]+1], (i ? dp[i-1] : 0) + nxt[i] - i);
		}
	}
	cout<<*max_element(dp,dp+n)<<'\n';
}


Measured memory_bytes: 15708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
    return 0;
  }
  if(a==1){
    cout<<"Alice"<<endl;
    return 0;
  }
  if(b==1){
    cout<<"Bob"<<endl;
    return 0;
  }

  if(b<a){
    cout<<"Alice"<<endl;
    return 0;
  }

  if(a<b){
    cout<<"Bob"<<endl;
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    map<int,int>mp;
    FOR(i,1,101){
        FOR(j,1,101){
            FOR(k,1,101){
                int f = i*i+j*j+k*k+i*j+j*k+k*i;
                if(f > 0)mp[f]++;
            }
        }
    }
    FOR(i,1,n+1){
        cout << mp[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Atcoder 2018

// Code below

llong n, y;

void inp() {
    cin >> n >> y;
}

void solve() {
    if (y % 1000 != 0) {
        cout << "-1 -1 -1";
        return;
    }
    y /= 1000;
    for (llong i = 0; i <= 2000; ++i) {
        for (llong j = 0; j <= 2000; ++j) {
            if (i + j <= n && (i * 5 + j * 10 + (n - i - j) == y)) {
                cout << j << ' ' << i << ' ' << (n - i - j);
                return;
            }
        }
    }
    cout << "-1 -1 -1";
    return;
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }

    #ifdef _DEBUG27_
        cout << endl << "Time: " << clock() / 1000.0 << " ms";
    #endif
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 256
# ABC 098: B – Cut and Count
n = int(input())
s = input()

set_s = set(s)
the_number = 0

for i in range(1, n):
    the_number_of_this_cut = 0

    x = set(list(s[:i]))
    y = set(list(s[i:]))

    for letter in set_s:
        if letter in x and letter in y:
            the_number_of_this_cut += 1
    
    the_number = max(the_number, the_number_of_this_cut)

print(the_number)

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

int main(){
  string str;
  int size, f = 0,count = 0;
  cin>>str;

  size = str.size();

  for(int i = 0; i < size; i++){
    if(str[i] == 'A' && f == 0) {f = 1;}
    if(str[i] == 'Z' && f == 1) {f=0; count++;}
  }

  if(count == 0) cout<<"-1"<<endl;
  else {
    for(int i = 0; i < count; i++){
      cout<<"AZ";
    }
    cout<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
class Program
    {
        public class Node
        {
            public List<int> childs = new List<int>();
            public int x = 0;
            public void connectTo(int n)
            {
                this.childs.Add(n);
            }
        }
        public static int get_ans(int id, bool[] looked, Node[] nodes, int[] ans)
            {
                if(looked[id] == true) return ans[id];
                looked[id] = true;
                int buf = nodes[id].x;
                foreach(int id_child in nodes[id].childs)
                {
                    if (looked[id_child] == true) continue;
                    nodes[id_child].x += buf;
                    get_ans(id_child, looked, nodes, ans);
                }
                ans[id] = buf;
                return buf;
            }
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' '); 
            int n = int.Parse(s1[0]), q = int.Parse(s1[1]);
            Node[] nodes = new Node[n];
            for(int i=0; i<n; i++)  nodes[i] = new Node();
            for (int i=0; i<n-1; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]) - 1, b = int.Parse(s[1]) - 1;
                nodes[a].connectTo(b);
                nodes[b].connectTo(a);
            }

            for (int i=0; i<q; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int p = int.Parse(s[0]) - 1, x = int.Parse(s[1]);
                nodes[p].x += x;
            }
            
            int[] ans = new int[n];
            bool[] looked = new bool[n];

            
            get_ans(0, looked, nodes, ans);

            StringBuilder sb = new StringBuilder("" + ans[0]);
            for (int i=1; i<n; i++) sb.Append(" " + ans[i]);
            Console.WriteLine(sb);

        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 81796
from itertools import permutations

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

def main():
    n, m, r = input_list()
    rlist = input_list()
    rlist = [r-1 for r in rlist]
    d = [[float('inf')]*n for i in range(n)]
    for i in range(n):
        d[i][i] = 0
    
    for i in range(m):
        a, b, c = input_list()
        d[a-1][b-1] = c
        d[b-1][a-1] = c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                distance = d[i][k]+d[k][j]
                if d[i][j] > distance:
                    d[i][j] = distance

    ans = float('inf')
    for p in permutations(rlist):
        distance = 0
        for i in range(r-1):
            distance += d[p[i]][p[i+1]]

        if ans > distance:
            ans = distance

    print(ans)

main()
        


Measured memory_bytes: 4724
s = input()
N = len(s)
x = 0
y = N-1
for i in range(N):
    if s[i] == 'A':
        x = i
        break
for i in range(N-1, -1, -1):
    if s[i] == 'Z':
        y = i
        break
print(y-x+1)

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

int n,mx =0,tp,ans=0;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
  REP(i,n){
    cin>>tp;
    ans +=tp;
    mx = max(mx,tp);
  }
  ans -= mx /2;
  cout<< ans <<endl;
} 


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

int main(){
    /*input*/
    string s;
    string t;
    cin >> s >> t;
    /*calculation*/
    int ans = 0;
    rep(i, 3){
	if(s[i] == t[i])ans++;
    }
    /*output*/
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
length, goal = map(int, input().split(" "))
problems, bonus = [], []
for i in range(length):
    a, b = map(int, input().split(" "))
    problems.append(a)
    bonus.append(b)
problems = problems[::-1]
bonus = bonus[::-1]
answer = float("inf")
for bit in range(2 ** length):
    temp_ans = 0
    temp_sum = 0
    for i in range(length):
        temp_score = (length - i) * 100
        if bit & (1 << i):
            temp_ans += problems[i]
            temp_sum += bonus[i] + temp_score * problems[i]
    # print(bit, temp_ans, temp_sum)
    if temp_sum >= goal:
        answer = min(answer, temp_ans)
    else:
        for i in range(length):
            temp_score = (length - i) * 100
            if not(bit & (1 << i)):
                if temp_score * (problems[i] - 1) + temp_sum >= goal:
                    temp_ans += int(math.ceil((goal - temp_sum) / temp_score))
                    # print(math.ceil((goal - temp_sum) / temp_score))
                    answer = min(answer, temp_ans)
                    break
                else:
                    temp_ans += problems[i] - 1
                    temp_sum += temp_score * (problems[i] - 1)
        if temp_sum >= goal:
            answer = min(answer, temp_ans)
print(answer)

Measured memory_bytes: 3064
s = input()
n = len(s)
for k in range(1,n):
    if s[k-1] == s[k]:
        print(k,k+1)
        exit(0)
if n >= 3:
    for k in range(1,n-1):
        if s[k-1] == s[k+1]:
            print(k,k+2)
            exit(0)
print(-1,-1)


Measured memory_bytes: 39408
import sys
input = sys.stdin.readline
INF = 100100100100100100

def main():
    N, M = map(int, input().split())
    dp = [INF] * (2**N)
    dp[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for i in c:
            key += 2 ** (i-1)
        for j in range(2**N):
            dp[j|key] = min(dp[j|key], dp[j]+a)
    if dp[2**N-1] == INF:
        print(-1)
    else:
        print(dp[2**N-1])


if __name__ == '__main__': main()

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

using namespace std;

int main() {
    int N;
    int Ti[100];
    int M;
    int Pi[100];
    int Xi[100];

    cin >> N;
    for (int i = 0; i < N; i++) cin >> Ti[i];
    cin >> M;
    for (int i = 0; i < M; i++) cin >> Pi[i] >> Xi[i];

    for (int d = 0; d < M; d++) {
        int total = 0;
        for (int i = 0; i < N; i++) {
            total += (Pi[d]-1 == i) ? Xi[d] : Ti[i];
        }
        cout << total << endl;
    }

    return 0;
}



Measured memory_bytes: 256
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();

    let ans = match cv.len() {
        1 => 0,
        2 => {
            if cv[0] == cv[1] {
                1
            } else {
                0
            }
        }
        n => {
            let mut c1 = 0; // 010101...
            let mut c2 = 0; // 101010...
            for i in 0..n {
                if cv[i] == '0' {
                    if i % 2 == 0 {
                        c2 += 1;
                    } else {
                        c1 += 1;
                    }
                } else if cv[i] == '1' {
                    if i % 2 == 0 {
                        c1 += 1;
                    } else {
                        c2 += 1;
                    }
                } else {
                    unreachable!();
                }
            }
            min(c1, c2)
        }
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  int i;
  vector<int> x(m);
  for(i=0;i<m;i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  vector<int> a(m-1);
  for(i=0;i<m-1;i++){
    a[i] = x[i+1] - x[i];
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(i=0;i<m-n;i++){
    ans += a[i];
  }
  cout << ans << endl;
}
    

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


int main() {
  string S;
  cin >> S;
  string K = "abcdefghijklmnopqrstuvwxyz";
  
  for(char k : K) {
    int i=0;
    for(char s : S) {
      if(k == s) {
        i=1;
      }
    }
    if(i==1) continue;
    else cout << k << endl;
    return 0;
  }
  
  
  cout << "None" <<endl;
  
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vint counts = vint(m + 1, 0);
    rep (xxxx, n) {
        int k;
        cin >> k;
        rep (i, k) {
            int a;
            cin >> a;
            counts[a]++;
        }
    }
    int ans = 0;
    rep (i, m + 1) {
        if (counts[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
int main()
{
    long long a,b,h,m;
  long double mi, ho,rad, distance;
    cin>>a>>b>>h>>m;
    mi = m/60.0;
    ho = m/720.00 + h/12.00;
    rad = 2*3.14159265358979323846*(mi-ho);
    distance = sqrt(a*a + b*b - 2 *a*b*cos(rad));
    cout<<fixed<<setprecision(20)<<distance;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
static vector<long long> AList;
static vector<long long> BList;

int main()
{
  // 入力受け取り
  int N;
  cin >> N;
  AList.resize(N+1);
  BList.resize(N);
  for (int i=0; i<N+1; i++) cin >> AList.at(i);
  for (int i=0; i<N; i++) cin >> BList.at(i);
  
  // 計算
  long long killed=0;
  for (int i=N; i >0; i--) {
    if (AList[i] < BList[i-1]) {
      killed+=AList[i];
      BList[i-1] -= AList[i];
      AList[i] = 0;
    }
    else {
      killed+=BList[i-1];
      AList[i] -= BList[i-1];
      BList[i-1] = 0;
    }
    
    if (AList[i-1] < BList[i-1]) {
      killed+=AList[i-1];
      BList[i-1] -= AList[i-1];
      AList[i-1] = 0;
    }
    else {
      killed+=BList[i-1];
      AList[i-1] -= BList[i-1]; 
      BList[i-1] = 0;  
    }  
  }
  
  // ans
  cout << killed << endl;
  
  return 0;
}

  

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		int[] nums = new int[NUM];
		for(int i = 0; i < NUM; i++){
			nums[i] = scan.nextInt();
		}
		
		//sort
		Arrays.sort(nums);
		
		// search
		Deque<Integer> stack = new ArrayDeque<>();
		for(int i = 0; i < NUM; i++){
			if(stack.size() > 0 && stack.peek() == nums[i]){
				stack.pop();
			} else {
				stack.push(nums[i]);
			}
			
		}
		
		// answer
		System.out.println(stack.size());
	}
}

Measured memory_bytes: 50184
N = int(input())
l = map(int,input().split())
l_t = [i for i in enumerate(l)]

a_j = 1 #レンガに書かれている整数
count = 0 #残るレンガの数
for i in range(len(l_t)):
  if l_t[i][1] == a_j: #整数と一致するvalueがあったら
    a_j += 1 #次の整数
    count += 1 #残していいレンガが一個増える
  else:
    continue
if N-count != N:
  print(N-count)
else:
  print(-1) 


Measured memory_bytes: 45340
n = int(input())
from collections import Counter


def calccnt(v):
    cnt = 0
    for _ in range(2):
        if v % 2 == 0:
            cnt += 1
            v = v // 2
    return cnt


cnt = Counter([calccnt(int(_)) for _ in input().split()])
# print(cnt)
if cnt[0] > 0:
    if cnt[0] > cnt[2] + 1:
        print('No')
        exit()
    if cnt[0] == cnt[2] + 1 and cnt[1] > 0:
        print('No')
        exit()
if n==1 and cnt[1]:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 11436
module union_find_mod
    use,intrinsic :: iso_fortran_env
    private
    type,public:: union_find
        integer(int32),allocatable:: parent(:)
    contains
        procedure:: unite => uf_unite
        procedure:: root => uf_root
    end type

    interface union_find
        module procedure:: uf_init
    end interface
contains
    function uf_init(n) result(uf)
        type(union_find):: uf
        integer(int32):: n

        allocate(uf%parent, source=[(i,i=1,n)])
    end function


    recursive function uf_root(uf,x) result(ret)
        class(union_find):: uf
        integer(int32):: x,ret
        
        if (uf%parent(x) == x) then
            ret = x
        else
            uf%parent(x) = uf%root(uf%parent(x))
            ret = uf%parent(x)
        end if
    end function


    subroutine uf_unite(uf,a,b)
        class(union_find):: uf
        integer(int32),intent(in):: a,b
        integer(int32):: ra, rb

        ra = uf%root(a); rb = uf%root(b)
        if (ra == rb) return
        uf%parent(ra) = rb
    end subroutine
end module


program main
    use,intrinsic :: iso_fortran_env
    use union_find_mod
    implicit none
    integer(int32):: n,m,i,a,b,ans
    type(union_find):: uf
    integer(int32), allocatable:: cnt(:)


    read*, n,m
    uf = union_find(n)
    allocate(cnt(n),source=0)

    do i=1,m
        read*, a,b
        call uf%unite(a,b)
    end do

    do i=1,n
        cnt(uf%root(i)) = cnt(uf%root(i)) + 1
    end do
    ans=0
    do i=1,n
        if (cnt(i) > 0) ans=ans+1
    end do
    print'(i0)',ans-1
end program main

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

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

int main()
{
	int n = read(), a = read(), b = read();
	if (abs(a - b) % 2 == 0)
		printf("Alice\n");
	else printf("Borys\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ps push_back
using namespace std;
void solve()
{

}
int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    long long n, m=7;
    int i;
    cin>>n;
    for(i=1; i<=1000000; i++)
    {
        if(m%n==0)break;
        m=(m*10+7)%n;
    }
    if(i<=1000000)printf("%d\n", i);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int n,h[123456],c;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=0;i<n;i++){
		int j=i,k=i+1,a=0;
		while(h[j]>=h[k]&&h[k]!=0){
			j++;
			k++;
			a++;
		}
		if(c<a)c=a;
		i=j++;
	}
	cout<<c;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	long double r;
	cin>>r;
	long double piee = 3.14159265358979323846;
	long double c = (2*piee*r);
	cout<<setprecision(15)<<c;

	
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li dp[10010];
li a[1010];

vector<li> c[1010];

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

    rep(i, bit(n)) {
        dp[i] = INF;
    }
    dp[0] = 0;

    rep(i, m) {
        li b;
        cin >> a[i] >> b;
        rep(j, b) {
            li cc;
            cin >> cc;
            cc--;
            c[i].pb(cc);
        }
    }

    rep(i, bit(n)) {
        if (dp[i] == INF)continue;
        bitset<15> bs(i);

        rep(j, m) {
            bitset<15> tmp = bs;
            for (auto && k : c[j]) {
                tmp[k] = 1;
            }
            dp[tmp.to_ulong()] = min(dp[tmp.to_ulong()], dp[i] + a[j]);
        }
    }

    if (dp[bit(n) - 1] == INF) {
        puts("-1");
    } else {
        cout << dp[bit(n) - 1] << endl;
    }

    return 0;
}

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

int main(){
	string ar[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s; cin >> s;
	for(int i = 0; i < 7; i++){
		if(s == ar[i]){
			cout << 7 - i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, a, b;
  cin >> n >> a >> b;

  int mina = n / b;
  if (n % b != 0) mina++;
  int maxa = n - b + 1;
  if (a < mina || a > maxa) {
    cout << -1 << '\n';
    return 0;
  }
  vector<int> cnt;
  int res = n;
  while (a > 0) {
    if (res == a) {
      cnt.push_back(1);
      res--;
    }
    else if (res - b < a - 1) {
      cnt.push_back(res - (a - 1));
      res = a - 1;
    }
    else {
      cnt.push_back(b);
      res -= b;
    }
    a--;
  }
  res = 0;
  rep(i, cnt.size()) {
    res += cnt[i];
    rep(j, cnt[i]) {
      cout << res - j << ' ';
    }
  }
  cout << '\n';





  
  return 0;
}

Measured memory_bytes: 3184
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

const int MAX = 1e9-1;
signed main() {
	int H,W,h,w;
	std::cin >> H >> W >> h >> w;
	if(H%h==0 && W%w==0) {
		print("No");
		return 0;
	}
	if((H/h+W/w+1)*(MAX)<=(H/h)*(W/w)) {
		print("No");
		return 0;
	}
	print("Yes");
	std::vector<std::vector<int> > hw(h,std::vector<int>(w,0));
	hw[0][0] = MAX; hw[h-1][w-1] = -MAX-1;

	for(int i=0;i<H;i++) {
		for(int j=0;j<W;j++) {
			std::cout << hw[i%h][j%w] << ' ';
		}
		std::cout << ENDL;
	}
	return 0;
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    string o, e; cin >> o >> e;

    string res = "";
    for (size_t i = 0; i < o.length(); ++i) {
        if (i < o.length()) res += o[i];
        if (i < e.length()) res += e[i];
    }

    cout << res << "\n";

    return 0;
}


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

int main(){
    int n,c,d=0,f;
    cin >> n;
    for(int i=1;i<=n;i++){
        c=0;
        int e=i;
        while(1){
            if(e%2==0){
                e/=2;
                c++;
            }else{
                break;
            }
        }
        if(c>=d){
            d=c;
            f=i;
        }
    }    
    cout << f;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r,c,n,max1;
    cin>>r>>c>>n;
    max1=max(r,c);
    if(n%max1==0)
    cout<<n/max1;
    else
    cout<<(n/max1)+1;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> lw(N, 0), re(N, 0);
    rep(i, N) {
        if (s[i] == 'W')
            lw[i] = 1;
        if (s[i] == 'E')
            re[i] = 1;
    }

    rep(i, N - 1) { lw[i + 1] += lw[i]; }

    for (int i = N - 1; i > 0; i--) {
        re[i - 1] += re[i];
    }

    rep(i, N) {
        if (s[i] == 'W')
            lw[i]--;
        if (s[i] == 'E')
            re[i]--;
    }

    int res = 1e8;
    rep(i, N) { res = min(res, re[i] + lw[i]); }
    cout << res << endl;
}

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

int main() {
  string S;
  cin>>S;
  if(S=="SUN") cout<<7<<endl;
  if(S=="MON") cout<<6<<endl;
  if(S=="TUE") cout<<5<<endl;
  if(S=="WED") cout<<4<<endl;
    if(S=="THU") cout<<3<<endl;
      if(S=="FRI") cout<<2<<endl;
        if(S=="SAT") cout<<1<<endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();

		int[] B = new int[M];
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextInt();
		}

		int ans = 0;

		for (int j = 0; j < N; j++) {
			int[] A = new int[M];

			int x = C;
			for (int i = 0; i < A.length; i++) {
				int a = sc.nextInt();
				x += (a * B[i]);
			}

			if (x > 0) {
				ans++;
			}

		}

		out.println(ans);
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main(){
    string s; cin >> s;
    int cnt=0,ans=0;
    for(int ix=0;ix<3;ix++){
        if(s.at(ix) == 'R') cnt++;
        else{
            cnt = 0;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	
	public static void Main()
	{	
		int N = Int32.Parse(Console.ReadLine());
		
		int[] x = new int[N];
		int[] y = new int[N];
		int[] h = new int[N];
		for(int i = 0; i < N; i++)
		{
			string[] args = Console.ReadLine().Split(' ');
			x[i] = Int32.Parse(args[0]);
			y[i] = Int32.Parse(args[1]);
			h[i] = Int32.Parse(args[2]);
		}
		
		int iPlus = -1;
		for(int i = 0; i < N; i++)
		{
			if(h[i] > 0)
			{
				iPlus = i;
				break;
			}
		}
		
		for(int Cx = 0; Cx <= 100; Cx++)
		{
			for(int Cy = 0; Cy <= 100; Cy++)
			{
				bool correct = true;
				int H = h[iPlus] + Math.Abs(x[iPlus] - Cx) + Math.Abs(y[iPlus] - Cy);
				for(int i = iPlus + 1; i < N; i++)
				{
					if(h[i] == 0)
						continue;  // next i
					
					if(h[i] + Math.Abs(x[i] - Cx) + Math.Abs(y[i] - Cy) != H)
					{
						correct = false;
						break;  // end i-loop
					}
				}
				if(!correct)
					continue;  // next Cy
				
				for(int i = 0; i < N; i++)
				{
					if(h[i] != 0)
						continue;  // next i
					
					if(H > Math.Abs(x[i] - Cx) + Math.Abs(y[i] - Cy))
					{
						correct = false;
						break;  // end i-loop
					}					
				}
				
				if(correct)
				{
					Console.WriteLine("{0} {1} {2}", Cx, Cy, H);
					return;
				}				
			}		
		}
	}	
}

Measured memory_bytes: 13140