akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;



int main(){
    int n; cin >> n;
    vector<int> c(n,0),s(n,0),f(n,0);
    REP(i,n-1) cin >> c[i] >> s[i] >> f[i];

    for(int i = 0; i < n; ++i){
        int time = s[i] + c[i];
        for(int j = i + 1; j < n - 1; ++j){
            if(time < s[j]) time = s[j]; // まだ始発してない
            else if(time % f[j] == 0); // 待ち時間があったら加算
            else time += f[j] - time % f[j];
            time += c[j];
        }
        cout << time << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    N = II()
    for h in range(1, 3501):
        for w in range(1, 3501):
            if (4 * h * w - N * w - N * h) == 0:
                continue
            n = N * h * w / (4 * h * w - N * w - N * h)
            if n.is_integer() and n > 0:
                print(h, w, int(n))
                return
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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(x);
  if(x==0){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3592
n = int(input())
L = []
for _ in range(n):
    L.append(int(input()))

def InsertionSort(L, n, g):  
    for i in range(n):
        global cnt
        v = L[i]
        j = i - g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v


def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i)

cnt = 0
ShellSort(L, n)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l, r; cin>>l>>r;
	vll M;
	for(ll i=l; i<=r&&i<l+2019; i++){
		M.pb(i%2019);
	}
	ll mini = 2019;
	for(int i=0; i<M.size(); i++){
		for(int j=i+1; j<M.size(); j++){
			mini = min(mini, (M[i]*M[j])%2019);
		}
	}
	cout << mini << endl;
	return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  
  if(S[0] == '7' || S[1] == '7' || S[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3600
N = int(input())
count = 0
cList = {}
s = 0
for i in range(1,N + 1):
    s = i
    while i % 2 != 1:
        i /= 2
        count += 1
    # print(f"{s}:{count}")
    cList[s] = count
    count = 0
# for c in cList.values():
#     print(c)
print(max(cList,key=cList.get))

Measured memory_bytes: 9244
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	String s;
	char[] chars;
	int N;
	public void solve() {
		s = next();
		N = s.length();
		chars = s.toCharArray();

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

			if(i + 1 < N){
				if(chars[i] == chars[i + 1]){
					out.println((i + 1) + " " + (i + 2));
					return;
				}
			}

			if(i + 2 < N){
				if(chars[i] == chars[i + 2]){
					out.println((i + 1) + " " + (i + 3));
					return;
				}
			}
		}

		out.println("-1 -1");

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)



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

  ll N,W,H;
  cin>>N>>W>>H;
  //vector<ll> flagx(W),flagy(H);
  vector<ll> vx(W+1),vy(H+1);
  FOR(i,0,N){
    ll a,b,c;
    cin>>a>>b>>c;
    ll l=max((ll)0,a-c),r=min(W,a+c);
    vx[l]++,vx[r]--;
    l=max((ll)0,b-c),r=min(H,b+c);
    vy[l]++,vy[r]--;
  }

  ll fx=0,fy=0;
  FOR(i,1,W){
    vx[i]+=vx[i-1];
  }
  FOR(i,1,H){
    vy[i]+=vy[i-1];
  }

  FOR(i,0,W){
    if(vx[i]==0)fx=1;
    //cout<<vx[i]<<" ";
  }
  //cout<<endl;
  FOR(i,0,H){
    if(vy[i]==0)fy=1;
    //cout<<vy[i]<<" ";
  }



  if(fx*fy==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 4424
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <set>

class UnionFind{
    std::vector<int> r,rank;
public:
    UnionFind(int N){
        for (int i = 0;i < N;i++){
            r.push_back(i);
            rank.push_back(0);
        }
    }
    int root(int x){
        if (r[x] == x){
            return x;
        }
        return r[x] = root(r[x]);
    }
    bool unite(int x,int y){
        x = root(x);
        y = root(y);
        if (x == y){
            return false;
        }
        if (rank[x] < rank[y]){
            r[x] = y;
        }
        else{
            r[y] = x;
            if (rank[x] == rank[y]){
                rank[x] += 1;
            }
        }
        return true;
    }
    int show(){
        std::set<int> jud;
        int co = 0;
        for (int i:r){
            auto iter = jud.find(root(i));
            if (iter == jud.end()){
                co += 1;
                jud.insert(root(i));
            }
        }
        return co;
    }
};

int main(){
    int n,m;
    std::cin >> n >> m;
    UnionFind UF(n);
    for (int i = 0;i < m;i++){
        int a,b;
        std::cin >> a >> b;
        a--;
        b--;
        UF.unite(a,b);
    }
    std::cout << UF.show() - 1 << std::endl;
}

Measured memory_bytes: 7480
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(unused_macros)]
macro_rules ! min {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr , $ (, ) * ) => {{std :: cmp :: min ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: min ($ a , min ! ($ ($ rest ) ,+ ) ) } } ; }
#[allow(unused_macros)]
macro_rules ! chmin {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_min = min ! ($ ($ cmps ) ,+ ) ; if $ base > cmp_min {$ base = cmp_min ; true } else {false } } } ; }

fn main() {
    input! {
        n: usize,
        k: usize,
        h_: [i32; n],
    }
    let mut h = h_.clone();
    h.sort();

    let mut ret = std::i32::MAX;
    for i in 0..=n-k {
        chmin!(ret, h[i + k - 1] - h[i]);
    }

    println!("{}", ret);
}


Measured memory_bytes: 2996
from operator import itemgetter
N = int(input())
X = list(map(int, input().split()))
data = []
for i in range(N):
    data.append([X[i],i])

data.sort()
k = (N//2) - 1
f = data[k][0]
s = data[k+1][0]
#print("f {}  s{}".format(f,s))
data = sorted(data, key = lambda x:x[1])
for i in range(N):
    if data[i][0] <= f:
        print(s)
    else:
        print(f)


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

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];

vector<int> cnt;
void dfs(int v) {
  if (visited[v]) return;
  visited[v] = true;
  cnt[v/V]++;
  for (int u : to[v]) dfs(u);
}

int main() {
  int n;
  cin >> n;
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    y += V;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  ll ans = 0;
  rep(i,V*2) {
    if (visited[i]) continue;
    cnt = vector<int>(2);
    dfs(i);
    ans += (ll)cnt[0]*cnt[1];
  }
  ans -= n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10240
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N, K;

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

  cout << static_cast<int>(floor(log(N) / log(K))) + 1 << endl;

  return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); }
 
using namespace std;
using ll = long long;

int main() { init_io();
  int r; cin >> r;
  cout << r * r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int dp[5005][5005];
int f(int a,int b,int limit){
	int&ret = dp[a][b];
	if(~ret) return ret; 
	if(s[a]!=s[b]) return ret = 0;
	
	if(b==n-1 || a==limit) return ret = 1;
	return ret = 1+f(a+1,b+1,limit);
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>s;
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans = max(ans,f(i,j,j-1));
		}
	}
	cout<<ans;
}

Measured memory_bytes: 101456
from fractions import gcd
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))

forward = ([0] + list(accumulate(A[::], gcd)))[:-1]
backward = ([0] + list(accumulate(A[::-1], gcd)))[::-1]

print(max([gcd(x, y) for x, y in zip(forward, backward[1:])]))

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

lli n;
pair<int,int> p[200005];
int dp[200005];
void solve()
{
    vector<pair<int,int> > v;
    v.push_back(make_pair(n,(int)2e9));
    dp[n]=1;
    for(int i=n-1;i>=0;i--)
    {
        while(v.back().second< p[i].first+p[i].second )
        {
            v.pop_back();
        }
        int j=v.back().first;
        dp[i]=dp[j];
        v.push_back(make_pair(i,p[i].first));
        dp[i]=(dp[i]+dp[i+1]) % mod;
    }
    cout<<dp[0]<<"\n";

}


int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
    {
        cin>>p[i].first>>p[i].second;
    }
    sort(p,p+n);
    solve();
	return 0;
}


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



int main(){
  ll n,m,i,ans;
  cin >> n >> m;
  if(n*2<=m){
    ans=n;
    m=m-n*2;
    ans+=m/4;
  }else{
    ans=m/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String strLine = br.readLine();
		int convertedLine = Integer.parseInt(strLine);
		
		int h = convertedLine / 60 / 60;
		int s = convertedLine % 60;
		int m = convertedLine / 60 % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
	
}


Measured memory_bytes: 24280
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long sum = 0;
    long min = long.MaxValue;
    int answer = 0;

    for(int i = 0; i < n; i++)
    {
      sum += nums[i];
    }

    for(int i = 0; i < n; i++)
    {
      if(Math.Abs(sum - n*nums[i]) < min)
      {
        min = Math.Abs(sum - n*nums[i]);
        answer = i;
      }
    }
    
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a == 1&&b >= 1){ cout << 1; }
	else if (a == 2&& b == 1){ cout << 1; }
	else if (a == 2&& b >= 2){ cout << 2; }
	else if (a == 3&& b <= 2){ cout << 2; }
	else if (a == 3&& b >= 3){ cout << 3; }
	else if (a == 4&& b <= 3){ cout << 3; }
	else if (a == 4&& b >= 4){ cout << 4; }
	else if (a == 5&& b <= 4){ cout << 4; }
	else if (a == 5&& b >= 5){ cout << 5; }
	else if (a == 6&& b <= 5){ cout << 5; }
	else if (a == 6&& b >= 6){ cout << 6; }
	else if (a == 7&& b <= 6){ cout << 6; }
	else if (a == 7&& b >= 7){ cout << 7; }
	else if (a == 8&& b <= 7){ cout << 7; }
	else if (a == 8&& b >= 8){ cout << 8; }
	else if (a == 9&& b <= 8){ cout << 8; }
	else if (a == 9&& b >= 9){ cout << 9; }
	else if (a == 10&& b <= 9){ cout << 9; }
	else if (a == 10&& b >= 10){ cout << 10; }
	else if (a == 11&& b <= 10){ cout << 10; }
	else if (a == 11&& b >= 11){ cout << 11; }
	else if (a == 12&& b <= 11){ cout << 11; }
	else if (a == 12&& b >= 12){ cout << 12; }
	return 0;
}
 
 

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    vector<int> values(5);
    for(int i = 0; i < 5; i++) {
        cin >> values[i];
        if(values[i] == 0){
            cout << i + 1 << endl;
            break;
        }
    }
}

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

    solve();
    
    return 0;
}



Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
  int m[10];
  int f=0;
  int s=0;
  int t=0;
  for(int i = 0; i < 10 ; i ++ ){
    cin>>m[i];
  }
  for(int i = 0; i < 10 ; i ++ ){
    if(m[f]<m[i])
      f=i;
  }
  //  cout<<"max mountain tall is "<<m[f]<<endl;
  // cout<<"number is"<<f<<endl;
  if(f==0)
    s=1;

  for( int i=0; i<10 ;i++){
    if(m[s]<m[i] && i!=f)
      s=i;
  }
  //cout<<"secount tall mountain is "<<m[s]<<endl;
  if(f==0 || s==0)
    t=1;
  if(f==1 || s==1)
    t=2;
  for(int i=0;i<10;i++){
    if(m[t]<m[i] && i!=f && i!=s)
      t=i;
  }
  // cout<<"third tall mountain is"<<m[t]<<endl;
  //cout<<"the number is "<<t<<endl;
  cout<<m[f]<<endl;
  cout<<m[s]<<endl;
  cout<<m[t]<<endl;






  return 0;
}

Measured memory_bytes: 3084
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, suma, sumb;
std::vector<LL>a, b, aa, bb;

int main()
{
	in >> N;
	a.resize(N), b.resize(N);
	rep(i, N) in >> a[i];
	rep(i, N) in >> b[i];
	aa.resize(N), bb.resize(N);
	rep(i, N)
	{
		if (a[i] > b[i]) bb[i] = a[i] - b[i];
		else
		{
			aa[i] = (b[i] - a[i]) / 2;
			if ((b[i] - a[i]) % 2 == 1)
			{
				bb[i] = 1;
				++aa[i];
			}
		}
	}
	rep(i, N)
	{
		suma += aa[i];
		sumb += bb[i];
	}
	out << (suma >= sumb ? "Yes" : "No") << std::endl;
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  int ans = 1 ;
  
  while(ans*2 <=n)
    ans *= 2 ;
  
  cout <<ans ;
 


}


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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


ll a[22];
ll p[22];

ll dp[1<<20];

int main(void){
	ll n,m;
	cin >> n >> m;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> p[i];

	rep(i,1<<n){
		if(i==0) continue;
		ll lcm=1LL;
		rep(j,n) if(i&(1<<j)){
			ll g=__gcd(lcm,a[j]);
			if(lcm/g>LONG_MAX/a[j]){
				lcm=0LL;
				j=n;
			}else
				lcm=lcm/g*a[j];
		}
		if(lcm<=0)
			dp[i]=0;
		else
			dp[i]=m/lcm;
	}

	rep(i,n)rep(j,1<<n) if(j&(1<<i)) dp[j]-=dp[j^(1<<i)];

	long double ans=0.0;

	rep(i,1<<n){
		long double pro=1.0;
		rep(j,n){
			if(i&(1<<j))
				pro*=1.0*p[j]/100;
			else
				pro*=1.0*(100-p[j])/100;
		}
		ans+=1.0*abs(dp[i])*pro;
	}
	cout.precision(10);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 9436
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
 
int N;
long long sum;
 
 
 
int main() {
    cin >> N;
    for (int i = 0;i<N;i++){
        if ( (i+1)%3 != 0 && (i+1)%5 != 0){
            sum += i+1;
        }
    }
    cout << sum << endl;
}


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

#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int check(string s, char c)
{
    bool ans = 0;
    rep(i, 3)
    {
        if (s[i] == c && s[i + 3] == c && s[i + 6] == c)
            ans = 1;
    }
    for (int i = 0; i < 9; i += 3)
    {
        if (s[i] == c && s[i + 1] == c && s[i + 2] == c)
            ans = 1;
    }
    if (s[0] == c && s[4] == c && s[8] == c || s[2] == c && s[4] == c && s[6] == c)
        ans = 1;

    return ans;
}

int main()
{

    string s;
    while (cin >> s)
    {
        if (check(s, 'o'))
            OP('o');
        else if (check(s, 'x'))
            OP('x');
        else
            OP('d');
    }
    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<math.h>
#include<stdio.h>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double dist;
    dist=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
    printf("%f\n",dist);
    return 0;
}


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

int main(void){
const int inf = 100000000;


int n,m;
cin >> n >> m;

int a[1000],b[1000],c[1000],dist[100][100];

for(int i = 0; i < m; ++i){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}

for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
if(i==j)
dist[i][j]=0;
else
dist[i][j]=inf;
}
}

for(int i = 0; i < m; ++i){
dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
}

for(int k = 0; k < n; ++k){
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}

int ans=m;
for(int i = 0; i < m; ++i){
bool shortest=false;
for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1;
}
}

cout << ans << endl;
}


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

int main() {
  int N, M, A;
  cin >> N >> M;
  priority_queue<int> Q;
  while (cin >> A) Q.push(A);
  for (int i = 0; i < M; i++) {
    int tmp = Q.top();
    Q.pop();
    Q.push(tmp / 2);
  }
  long sum = 0;
  while (Q.size()) {
    sum += Q.top();
      Q.pop();
  }
  cout << sum << "\n";
}

Measured memory_bytes: 892
#define MAX 500001
int H[MAX];
int n;
void maxHeapify(int i){

  int l,r;
  int largest,tmp;
  l=left(i);
  r=right(i);

  if(n+1>l && H[l]>H[i]) largest = l;
  else largest=i;
  if(n+1>r && H[r]>H[largest]) largest=r;
  if(largest!=i){
    tmp=H[i];
    H[i]=H[largest];
    H[largest]=tmp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(){
  int i;
  for(i=n/2;i+1>1;i--){
    maxHeapify(i);
  }
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }
  buildMaxHeap();
  for(i=1;i<=n;i++){
    printf(" %d",H[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2548
from collections import defaultdict
from math import factorial
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, input().split())
    if abs(N - M) > 1:
        print(0)
        return
    ans = 1
    for i in range(1, N + 1):
        ans = (ans * i) % MOD
    for i in range(1, M + 1):
        ans = (ans * i) % MOD

    if N == M:
        ans *= 2
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=1e6+10;
const int mod=1e9+7;
const double pi=3.1415926535;

ll fac[maxn];
ll inv[maxn];
ll power(ll base, ll n)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%mod;
        base=base*base%mod;
        n/=2;
    }
    return r;
}

void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    inv[maxn-1]=power(fac[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;i--)
    {
        inv[i]=inv[i+1]*(i+1)%mod;
    }
}
ll C(ll m,ll n)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;

}




int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    int x,y;
    cin>>x>>y;
    int cntx=0;
    int cntxy=0;
    int f=0;
    for(int i=1;i<maxn;i++)
    {
        if(y%2==0&&x==y/2)
        {
            cntxy+=cntx+x;
            f=1;
            break;
        }
        if(x<2||y<1)
            break;
        cntx++;
        x-=2;
        y--;

    }
    //cout<<cntx<<" "<<cntxy<<'\n';
    if(f==0)
        cout<<0<<'\n';
    else
        cout<<C(cntx,cntxy)<<'\n';









}


Measured memory_bytes: 19280
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long A, B, C, K;

int main() {
    while (cin >> A >> B >> C >> K) {
        if (K & 1) cout << B-A << endl;
        else cout << A-B << endl;
    }
}















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

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>s(h);
    vector<vector<int>>ans(h,vector<int>(w,-1));
    vector<bool>ok(h,false);
    rep(i,h)cin>>s[i];
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')ok[i]=true;
    }
    int now=0;
    rep(i,h){
        if(!ok[i])continue;
        int cnt=0;
        now++;
        rep(j,w){
            if(s[i][j]=='#')cnt++;
            if(s[i][j]=='#'&&cnt>=2)now++;
            ans[i][j]=now;
        }
    }
    int start=0,goal=0;
    while(1){
        bool go=true;
        for(int i=start; i<h; ++i){
            if(ok[i]){
                goal=i;
                go=false;
                break;
            }
        }
        if(go)break;
        for(int i=goal; i>start; --i){
            rep(j,w){
                ans[i-1][j]=ans[i][j];
            }
        }
        start=goal+1;
    }
    for(int i=start-1; i<h-1; ++i){
        rep(j,w){
            ans[i+1][j]=ans[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(j!=w-1)cout<<ans[i][j]<<" ";
            else cout<<ans[i][j]<<endl;
        }
    }
    return 0;
}

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

int main(void){
  int n, m;

  cin >> n >> m;

  int A[n][m], b[m], c[n];

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

  for( int i = 0; i < m; i++){
    cin >> b[i];
  }

  for( int i = 0; i < n; i++){
    c[i] = 0;
  }

  for( int i = 0; i < n; i++){
    for( int j = 0; j < m; j++){
      c[i] += A[i][j]*b[j];
    }
  }

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

Measured memory_bytes: 3072
N = int(input())
W = [int(w) for w in input().split()]
S1 = 0
S2 = 0
ans = []
for i in range(N):
  S2 = sum(W) - S1
  ans.append(abs(S2 - S1))
  S1 = 0
  S2 = 0
  for j in range(i + 1):
    S1 += W[j]
print(min(ans))

Measured memory_bytes: 9136
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc176
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc176C();
            Console.Out.Flush();
        }

        public static void solve_abc176C()
        {
            long n = Convert.ToInt32(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long cnt = 0;
            long max = a[0];
            for (int i = 1; i < n; i++)
            {
                if (a[i] < max)
                {
                    cnt += max - a[i];
                }
                max = Math.Max(max, a[i]);
            }
            Console.WriteLine(cnt);
        }

        public static void solve_abc176B()
        {
            string s = Console.ReadLine();
            int sum = 0;
            for (int i = 0; i < s.Length; i++)
            {
                sum += Convert.ToInt32(s[i].ToString());
            }
            Console.WriteLine(sum % 9 == 0 ? "Yes" : "No");
        }

        public static void solve_abc176A()
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int w = (a[0] + a[1] - 1) / a[1];
            Console.WriteLine(w * a[2]);
        }
    }
}

Measured memory_bytes: 48012
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
bool compare(pair<ll,ll> &p1, pair<ll,ll> &p2)
{
    return p1.s<p2.s;
}
void solve()
{
    ll n;  cin>>n;
    vector<pair<ll,ll>> vp;
    rep(i,0,n)
    {
        ll x,y; cin>>x>>y;
        vp.pb({x,y});
    }
    sort(all(vp),compare);
    ll ans=0,last=0;
    rep(i,0,n)
    {   
        if(last+vp[i].f<=vp[i].s) 
        {
            ans++;
            last+=vp[i].f;
        }
    }cout<<(ans==n?"Yes":"No");
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


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

int main(void)
{
	int number,*values,i,j,max,sum;

	scanf("%d",&number);

	while(number != 0)
	{
		values = (int *)malloc(sizeof(int) *number);
		max = -100001;
		for(i = 0;i < number ; i++)
		{
			scanf("%d",&values[i]);
		}

		for(i = 0;i<number ; i++)
		{
			sum = 0;
			for( j = i; j < number ;j++)
			{
				sum += values[j];
				if(max < sum)
				{
					max = sum;
				}
			}
		}

		printf("%d\n",max);
		scanf("%d",&number);
	}

	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long m, k;
	cin >> m >> k;

	if (m == 0) {
		if (k == 0)
			printf("0 0\n");
		else
			printf("-1\n");

		return 0;
	}

	if (m == 1) {
		if (k == 0)
			printf("1 1 0 0\n");
		else
			printf("-1\n");

		return 0;
	}

	long long lim = (1<<m) - 1;
	if (k > lim) {
		printf("-1\n");
		return 0;
	}

	for (long long i = 0; i <= lim; ++i)
		if (i != k)
			cout << i << " ";

	cout << k << " ";
	for (long long i = lim; i >= 0; --i)
		if (i != k)
			cout << i << " ";
	cout << k << endl;

	return 0;
}

Measured memory_bytes: 1792
s = gets.chomp
ans = 0
if s == "SUN"
  ans = 7
elsif s == "MON"
  ans = 6
elsif s == "TUE"
  ans = 5
elsif s == "WED"
  ans = 4
elsif s == "THU"
  ans = 3
elsif s == "FRI"
  ans = 2
elsif s == "SAT"
  ans = 1
end
puts ans 

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, p, a[5000], b[5000], c[5000];
LL d[2500];
LL const INF = 1e12;

int main() {
	cin >> n >> m >> p;
	{
		vector<array<LL, 3>> v;
		inc(i, m) {
			array<LL, 3> A;
			cin >> A[0] >> A[1] >> A[2];
			A[0]--; A[1]--;
			A[2] -= p;
			v.PB(A);
		}
		sort(ALL(v));
		inc(i, m) {
			a[i] = v[i][0];
			b[i] = v[i][1];
			c[i] = v[i][2];
		}
	}
	
	inc(i, n) { d[i] = -INF; }
	d[0] = 0;
	
	inc(q, n * 3) {
		bool cont = false;
		inc(i, m) {
			bool flag = setmax(d[ b[i] ], d[ a[i] ] + c[i]);
			cont |= flag;
			if(flag && q >= n && b[i] == n - 1) { cout << -1 << endl; return 0; }
		}
		if(! cont) { break; }
	}
	
	cout << max(0LL, d[n - 1]) << endl;
	
	return 0;
}


Measured memory_bytes: 576
n, q = map(int, input().split())
s = input()
cnts = [0]

for i in range(1, n):
  if s[i] == 'C' and s[i-1] == 'A':
    cnts.append(cnts[i-1] + 1)
  else:
    cnts.append(cnts[i-1])

# for l in range(1, n+1):
#   for r in range(l+1, n+1):
#     ll = l-1
#     rr = r-1
#     cnt = cnts[rr] - cnts[ll]
#     subs = s[ll:rr+1]
#     print('{2}: {0} ACs found in {1}'.format(cnt, subs, (l,r)))
for qq in range(q):
  l, r = map(int, input().split())
  cnt = cnts[r-1] - cnts[l-1]
  print(cnt)


Measured memory_bytes: 6176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int h,w; cin>>h>>w;
    char c[h][w]; rep(i,h)rep(j,w) cin>>c[i][j];
    bool hh[h],ww[w];
    rep(i,h) hh[i]=1;
    rep(i,w) ww[i]=1;
    rep(i,h)rep(j,w){
        if(c[i][j]=='#') hh[i]=0;
    }
    rep(i,w)rep(j,h){
        if(c[j][i]=='#') ww[i]=0;
    }
    rep(i,h){
        bool flg=0;
        rep(j,w){
            if(hh[i]||ww[j]) continue;
            cout<<c[i][j];
            flg=1;
        }
        if(flg) cout<<endl;
    }
    return 0;
}


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

long long k, s, dp[5][2505*3];

int dfs(int now,int sum)
{
	if(now>3) return !sum;
	if(dp[now][sum]!=-1) return dp[now][sum];
	int i,res=0;
	for(i=0; i<=k; i++) res+=dfs(now+1,sum-i);
	return dp[now][sum]=res;
}

int main ()
{
	memset(dp,-1,sizeof(dp));
	cin >> k >> s;
	cout<<dfs(1,s);
}

Measured memory_bytes: 512
n,m = map(int, input().split())
ball_cnts = [1]*(n+1)
ball_cnts[0] = 0
red_flag = [False]*(n+1)
red_flag[1] = True

for _ in range(m):
    x,y = map(int, input().split())
    if red_flag[x]:
        red_flag[y] = True
    if ball_cnts[x] == 1:
        red_flag[x] = False
    ball_cnts[x] -= 1
    ball_cnts[y] += 1

ans = 0
for v in red_flag:
    if v: ans += 1

print(ans)

Measured memory_bytes: 76428
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int LCM = 55440;
int sum[25][55555];
int getMax(int d){
    int mx = 0;
    for(int i=0;i<d;i++)mx = max(mx, sum[d][i]);
    return mx;
}
int main(){
    for(int N;cin>>N, N;){
        int ans = 0;
        for(int i=0;i<25;i++){
            for(int j=0;j<55555;j++){
                sum[i][j]=0;
            }
        }
        for(int n=0;n<N;n++){
            int d, t;
            cin>>d>>t;
            vector<int>vec(d);
            for(int i=0;i<d;i++){
                cin>>vec[(i - t + d) % d];
            }
            if(d==13 || d==17 || d==19 || d==23){
                for(int i=0;i<d;i++){
                    sum[d][i] += vec[i];
                }
            }
            else{
                for(int i=0;i<LCM;i++){
                    sum[0][i] += vec[i%d];
                    ans = max(ans, sum[0][i]);
                }
            }
        }
        ans += getMax(13);
        ans += getMax(17);
        ans += getMax(19);
        ans += getMax(23);
        cout<<ans<<endl;
    }

    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;
ll n,k,r;
ll pc[4005];

ll ppow(ll a,ll b){
    if (b==0) return 1;
    ll tm=ppow(a,b/2);
    if (b&1) return (tm*tm%MOD)*a%MOD;
    return tm*tm%MOD;
}

ll comb(ll n,ll k){
    return pc[n]*ppow(pc[k]*pc[n-k]%MOD,MOD-2)%MOD;
}

ll sol(ll a){
    ll mxmid=k-1;
    ll mid=a-1;
    if (r<mid){
        return 0;
    }

    ll res=comb(mxmid,mid);
    ll sisa=r-mid;
    res=res*comb(sisa+a,a)%MOD;

    return res;
}


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

    pc[0]=1;
    for (ll i=1;i<4005;i++){
        pc[i]=pc[i-1]*i%MOD;
    }
    
    cin >> n >> k;
    r=n-k;
    
    for (ll i=1;i<=k;i++){
        cout << sol(i) << el;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int w;
  string S,ans;
  cin >> S; 
  cin >> w; //入力
  for(int i=0;i*w<S.size();i++){ 
  ans += S.substr(i*w,1);
  }
  cout << ans << "\n";    //出力
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        long A = scan.nextInt();
        long B = scan.nextInt();
        long[] h = new long[N];
        for (int i = 0; i < N; i++) {
            h[i] = scan.nextLong();
        }

        long l = 0;
        long r = 1000000001;
        long m;
        while (r - 1 > l) {
            m = (l + r) / 2;
            long need = 0;
            //---------------------------//
            for(int i=0; i<N; i++){
                long tmp;
                tmp = h[i] - B*m; //
                if(tmp>0){
                    if(tmp%(A-B) == 0){
                        need += tmp/(A-B);
                    }else{
                        need += tmp/(A-B)+1;
                    }
                }
            }
            if(need > m){
                l=m;
            }else{
                r=m;
            }
            //----------------------------//
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 51992
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long ll;

char s[100005]; int n;
bool dp[100005];

int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (i >= 5 && s[i - 4] == 'd' && s[i - 3] == 'r' && s[i - 2] == 'e' && s[i - 1] == 'a' && s[i] == 'm') dp[i] |= dp[i - 5];
		if (i >= 7 && s[i - 6] == 'd' && s[i - 5] == 'r' && s[i - 4] == 'e' && s[i - 3] == 'a' && s[i - 2] == 'm' && s[i - 1] == 'e' && s[i] == 'r') dp[i] |= dp[i - 7];
		if (i >= 5 && s[i - 4] == 'e' && s[i - 3] == 'r' && s[i - 2] == 'a' && s[i - 1] == 's' && s[i] == 'e') dp[i] |= dp[i - 5];
		if (i >= 6 && s[i - 5] == 'e' && s[i - 4] == 'r' && s[i - 3] == 'a' && s[i - 2] == 's' && s[i - 1] == 'e' && s[i] == 'r') dp[i] |= dp[i - 6];
	}
	
	puts(dp[n] ? "YES" : "NO");
	
	return 0;
}


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

using namespace std;

int N;
vector< int > g[100000];
int dp[100000];

bool rec(int idx, int par, int length)
{
  vector< int > vs;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    if(!rec(to, idx, length)) return (false);
    if(dp[to] + 1 > length) return (false);
    vs.push_back(dp[to] + 1);
  }
  sort(begin(vs), end(vs));

  auto check = [&](int idx)
  {
    deque< int > st;
    for(int i = 0; i < vs.size(); i++) {
      if(i == idx) continue;
      st.push_back(vs[i]);
    }
    while(!st.empty()) {
      if(st.back() + st.front() > length) return (false);
      st.pop_back();
      st.pop_front();
    }
    return (true);
  };

  if(vs.size() % 2 == 0) {
    if(check(-1)) {
      dp[idx] = 0;
      return (true);
    }
    vs.pop_back();
  }

  int ok = (int) vs.size(), ng = -1;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  if(ok == vs.size()) return (false);
  dp[idx] = vs[ok];
  return (true);
}

bool check(int v)
{
  int root = -1;
  for(int i = 0; i < N; i++) {
    if(g[i].size() & 1) root = i;
  }
  return (rec(root, -1, v));
}

int main()
{
  cin >> N;
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int A = 1;
  for(int i = 0; i < N; i++) {
    A += g[i].size() & 1;
  }

  int ok = N, ng = 0;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }

  cout << A / 2 << " " << ok << endl;
}


Measured memory_bytes: 35840
#include <stdio.h>
#include <string.h>
int main(void){
	int N,M,A,B[20],C,i,j,s,ans=0;
	scanf("%d %d %d",&N,&M,&C);
	for(i=0;i<M;i++)scanf("%d",&B[i]);
	for(i=0;i<N;i++){
		s = 0;
		for(j=0;j<M;j++){
			scanf("%d",&A);
			s += A*B[j];
		}
		if(s+C>0)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    a, b = MII()
    print(divc(a+b, 2))

if __name__ == '__main__':
    main()

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

using namespace std;

#define db(m)  cout<<#m<<" = "<<m<<"\n"

#define MAX 10005
typedef long long ll;

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

    int q; cin>>q;
    map<string, int>mp;
    while(q--){
        string s; cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";

    return 0;
}
// Check corner case for 1
//Check constraint & SIZE

Measured memory_bytes: 3608