akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main(int argc, char *argv[]){
    ll N, K;
    string S;
    cin >> N >> K >> S;
    replace(S.begin() + K - 1, S.begin() + K, 'A', 'a');
    replace(S.begin() + K - 1, S.begin() + K, 'B', 'b');
    replace(S.begin() + K - 1, S.begin() + K, 'C', 'c');
    
    cout << S << endl;
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc129d()
}

fun abc129d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val wall = Array(h) { BooleanArray(w) }
    repeat(h) { i ->
        wall[i] = readLine()!!.map { it == '#' }.toBooleanArray()
    }

    // down,up,right,left
    val cSumD = Array(h) { IntArray(w) }
    val cSumU = Array(h) { IntArray(w) }
    val cSumR = Array(h) { IntArray(w) }
    val cSumL = Array(h) { IntArray(w) }

    for (x in 0 until w) {
        for (y in 0 until h) {
            cSumD[y][x] = if (wall[y][x]) 0 else if (y == 0) 1 else cSumD[y - 1][x] + 1
            cSumR[y][x] = if (wall[y][x]) 0 else if (x == 0) 1 else cSumR[y][x - 1] + 1
        }
    }
    for (x in w - 1 downTo 0) {
        for (y in h - 1 downTo 0) {
            cSumU[y][x] = if (wall[y][x]) 0 else if (y == h - 1) 1 else cSumU[y + 1][x] + 1
            cSumL[y][x] = if (wall[y][x]) 0 else if (x == w - 1) 1 else cSumL[y][x + 1] + 1
        }
    }

    var answer = 0

    for (y in 0 until h) {
        for (x in 0 until w) {
            val curr = cSumD[y][x] + cSumU[y][x] + cSumR[y][x] + cSumL[y][x] - 3
            if (curr > answer) answer = curr
        }
    }

    println(answer)
}


Measured memory_bytes: 112296
def ABC106():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def ABC122():
    S = SI()
    ans = 0
    cur = 0
    d = {"A","C","G","T"}
    for s in S:
        if s in d:
            cur += 1
        else:
            ans = max(ans,cur)
            cur = 0
    ans = max(ans,cur)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    ABC122()

"""

"""

Measured memory_bytes: 5100
def binary_search(arr,key):
	left = 0 
	right = len(arr)
	while left < right:
		mid = (left + right)//2
		if arr[mid] == key:
			return mid 
		elif arr[mid] < key:
			left = mid + 1
		else:
			right = mid
	return -1
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
count = 0
for i in range(q):
	if binary_search(S, T[i]) != -1:
		count += 1

print(str(count))



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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N);
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    if(a==1) cnt.at(b-1)++;
    if(b==N) cnt.at(a-1)++;
  }
  string ans = "IMPOSSIBLE";
  for(int i=0; i<N; i++){
    if(cnt.at(i)==2) ans="POSSIBLE";
  }
  cout << ans << endl;
}

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

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

  if(l+n-1<0)cout<<n*(n+1)/2+n*(l-1)-(l+n-1)<<endl;
  else if(l<0)cout<<n*(n+1)/2+n*(l-1)<<endl;
  else cout<<n*(n+1)/2+n*(l-1)-l<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long cur = 100;
long long n;
int main() {
	cin >> n;
	for (int i = 1; i <= 10000; i++) {
		cur = cur + cur * 0.01;
		if (cur >= n) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var x = Console.ReadLine().ToInt();
		var a = Console.ReadLine().ToInt();
		var b = Console.ReadLine().ToInt();
		
		Console.WriteLine(x-a-((x - a) / b)*b);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction

# 10進数表記でnのk進数を求めてlength分0埋め
def ternary (n, k, length):
    if n == 0:
        nums = ['0' for i in range(length)]
        nums = ''.join(nums)
        return nums
    nums = ''
    while n:
        n, r = divmod(n, k)
        nums += str(r)
    nums = nums[::-1]
    nums = nums.zfill(length)
    return nums


def main():
    num = int(input())
    data = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    max_length = len(bin(max(data))) - 2
    bit_count = [0 for i in range(max_length)]

    for i in range(num):
        now_bin = bin(data[i])[2:]
        now_bin = now_bin.zfill(max_length)
        for j in range(max_length):
            if now_bin[j] == "1":
                bit_count[j] += 1

    flg_data = [0 for i in range(max_length)]


    for i in range(max_length):
        flg_data[i] += bit_count[i] * (num - bit_count[i])

    ans = 0
    for j in range(max_length):
        pow_num = max_length - 1 - j
        bbb = pow(2, pow_num, mod)

        ans += bbb * flg_data[j]
        ans %= mod

    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 123564
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=5e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n,L;
void input()
{	
	n=read<int>(),L=read<int>();
}
double tmp[N],ans;
ll now,V[N];
int l=1,r;
#define sum(x,y) (V[y]-V[x-1])
void work()
{
	int t,v;
	ll nexv,vv;
	For(i,1,n)
	{
		t=read<int>(),v=read<int>();
		tmp[++r]=t,V[r]=V[r-1]+v;
		now+=v;ans+=1ll*t*v;
		for(;r>1&&tmp[r-1]>=tmp[r];r--)
		{
			nexv=min((ll)L,sum(r-1,r));	
			vv=nexv-sum(r,r);
			if(r>l)ans-=tmp[r-1]*(sum(r-1,r-1)-vv);
			//cerr<<vv<<endl;
			//cerr<<tmp[r-1]<<endl;
			//cerr<<tmp[r]<<' '<<sum(r,r)<<' '<<vv<<endl;
			tmp[r-1]=(tmp[r]*sum(r,r)+tmp[r-1]*vv)/(1.0*nexv);
			//cerr<<tmp[r-1]<<endl;
			V[r-1]=nexv+V[r-2];
		}
		//For(j,1,r)printf("%.7lf %lld\n",tmp[j],V[j]-V[j-1]);
		//cerr<<r<<endl;
		cmin(l,r);
		for(;l<r&&sum(l+1,r)>=L;l++)ans-=tmp[l]*sum(l,l);
		//cerr<<l<<' '<<r<<endl;
		//cerr<<ans<<endl;
		printf("%.7lf\n",(ans-(sum(l,r)-L)*tmp[l])/(1.0*L));
	}
}
int main()
{

//	file();
	input();
	work();
	return 0;
}


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

using namespace std;

void solve()
{
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    int arr[5] = {a, b, c, d, e};

    for (int i = 0; i < 5; i++){
        if(arr[i] == 0)
            cout << i+1;
    }

}

int main()
{
    solve();
    cout << "\n";
}


Measured memory_bytes: 3584
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a = -111, b = -111;
	int m;
	int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	//char a[1000000];
	//int a[200000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	//int box[1000000000000000000];
	int box=0;
	//int box2;
	//int p[1111];

	//long double aaa;

	int count = 0;
	//int k, d;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//bool flag = true;
	bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	cin >> n;
	//cin >> a >> b;
	//cin >> n >> m >> k;
	//for (int i = 0; i < n; i++)
	//{
	//	cin >> p[i];
	//}

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';
	for (int i = 0; i < 1000; i++)
	{
		if (n < 1000)
		{
			all = 1000 - n;
			break;
		}
		n -= 1000;
		if (n == 0)
		{
			all = 0;
			break;
		}
	}

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	cout << all << "\n";
	//cout << box << "\n";
	//cout << a << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        long arr[] = new long[n];
        long sum = 1;
        boolean flag = true,ff=false;
        for(int i=0;i<n;i++){
            arr[i]=s.nextLong();
            if(arr[i]==0){
                ff = true;
            }
        }
        if(ff){
            System.out.println(0);
        }
        else{
            for(int i=0;i<n;i++){
                if(((long)(1e18))/sum >=arr[i])sum*=arr[i];
                else {
                    flag = false;
                    break;
                }
            }
            System.out.println(flag?sum:-1);
        }


    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 48200
n,m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
if n>=m then
  print 0
  exit
end
a = a.sort
sum = 0
diff_array = []
a.each_with_index do |v,i|
  diff_array.push({"index": i, "value": v-a[i-1]}) if i-1 >= 0
end

diff_array.sort! do |a, b|
  b[:value] <=> a[:value]
end

(n-1).times do |i|
  diff_array[i][:set] = true
end

diff_array.sort! do |a, b|
  a[:index] <=> b[:index]
end

diff_array.each do |v|
  sum += v[:value] unless v[:set]
end
p sum

Measured memory_bytes: 37496
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int MXN = 8;

int n, m;
vector<bool> vis(MXN);
vector<int> adj[MXN];

ll dfs(int cur) {
	ll ans = 0;
	vis[cur] = true;
	bool all = true;
	for (int i=0; i<n && all; i++)
		if (!vis[i]) all = false;
	if (all) {
		vis[cur] = false;
		return 1;
	}
	for (int x : adj[cur])
		if (!vis[x]) ans += dfs(x);
	vis[cur] = false;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i=0; i<m; i++) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	cout << dfs(0);
}

Measured memory_bytes: 256
// AOJ 2755: Checkered Pattern
// 2018.1.6 bal4u@uu

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int main()
{
	int t;
	long long h, w, a, b, g;

	t = in();
	while (t--) {
		h = in(), w = in();
		if (h == w) puts("1 0");
		else if (!(h & 1) || !(w & 1)) puts("1 1");
		else {
			g = gcd(h, w), h /= g, w /= g;
			b = h*w >> 1, a = b+1;
			g = gcd(a, b);
			printf("%lld %lld\n", a/g, b/g);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int n, m, x, y;

    cin >> n; 
    cin >> m;
    cin >> x; 
    cin >> y;

    int _x[n];
    int _y[m];

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

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

    sort(_x, _x+n);
    sort(_y, _y+m);

    int c = _y[0];

    int flag = 0;

    if(_x[n-1] < c){
        flag++;
    }
    if(_y[0] >= c){
        flag++;
    }

    if(x<c && c <= y){
        flag ++;
    }

    if(flag == 3){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 3632
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;

map<int,int> freq;
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        freq[2]++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            freq[i]++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        freq[n]++;
}  

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



    int n;cin>>n;
    for(int i=2;i<=n;i++){
    	primeFactors(i);
    }

    int res=1;
    for(auto x:freq){
    	if(x.first!=1)
    	res=res*(x.second+1);
    res%=MOD;
    }

    cout<<res<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

void dfs(vector<ll> &counts, vector<ll> &ids, vector<vector<ll>> &graph, ll start, ll id) {
    ll count = 0;
    stack<ll> todo;
    vector<bool> seen(graph.size(), false);
    todo.push(start);
    seen[start] = true;
    ids[start] = id;
    while(!todo.empty()) {
        ll current = todo.top();
        todo.pop();
        count++;
        for(auto &e: graph[current]) {
            if(seen[e]) continue;
            seen[e] = true;
            ids[e] = id;
            todo.push(e);
        }
    }
    counts.push_back(count);
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> ids;
    vector<vector<ll>> friends;
    vector<ll> ans;
    ll id = 0;
    vector<ll> counts;
    friends.resize(N);
    ans.resize(N);
    for(ll i = 0;i < M;i++) {
        ll a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    ids.assign(N, -1);
    for(ll i = 0;i < friends.size();i++) {
        if(ids[i] == -1) dfs(counts, ids, friends, i, id++);
        ans[i] = counts[ids[i]] - 1 - friends[i].size();
    }
    for(ll i = 0;i < K;i++) {
        ll a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        if(ids[a] == ids[b]) {
            ans[a]--;
            ans[b]--;
        }
    }
    for(ll &i: ans) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 9460
import sys
from heapq import heappush, heappop
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    ab = []

    for i in range(N):
        a, b = in_nn()
        ab.append((a + b, a, b))

    ab.sort(reverse=True)

    taka = 0
    for i in range(0, N, 2):
        taka += ab[i][1]
    aoki = 0
    for i in range(1, N, 2):
        aoki += ab[i][2]

    ans = taka - aoki
    # print(ab)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    string t;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0')
        t += '0';
        if(s[i] == '1')
        t += '1';
        if(s[i] == 'B'){
        if(t.size() != 0)
        t.erase(t.size() - 1);
        }
    }
    for(int i = 0; i < t.size(); i++)
        cout << t[i];
        cout << endl;
}

Measured memory_bytes: 256
# print("Input N")
N = int(input())

# Need a Nx3 array for the DP. Will store the max points after N days,
#   which ends by doing activity 0, 1, or 2.

dp = [[0 for i in range(3)] for j in range(N)]

# print("Input the first three activity values")
a, b, c = [int(x) for x in input().split()]
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c

# Now input all the rest and update the dp array
for i in range(1, N):
    # print("Input the next three activity values")
    a, b, c = [int(x) for x in input().split()]
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[N-1]))


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

int main(){
  long long int x,y,r,q,a,b;
  while(scanf("%lld %lld",&x,&y) != EOF){
    a = x;
    b = y;
    while(1){
      q = x/y;
      r = x -q*y;
      if(r == 0) break;
      x = y;
      y = r;
    }
    x = a*b / y;
    cout << y << " " <<  x << endl;
  }
}

Measured memory_bytes: 1208
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int c[2] = {0, 0};
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        c[x % 2]++;
    }
    if (c[1] % 2 == 1) {
        cout << "NO\n";
    }
    else {
        cout << "YES\n";
    }
    return 0;
}

Measured memory_bytes: 3588
#coding: UTF-8

while True:
	l = raw_input().split()

	H = int(l[0])
	W = int(l[1])

	if H == 0 and W == 0:
		break

	else :
		a = 1
		print "#" * W
		x = "#"+"." * (W-2)+"#"

		while a < H - 1:
			print x
			a += 1

		print "#" * W + "\n"

Measured memory_bytes: 6444
n, a, b = map( int, input().split() )
if a > b:
  exit( print( 0 ) )
if n == 1:
  exit( print( 1 if a == b else 0 ) )
else:
  x = ( n - 1 ) * a + b
  y = ( n - 1 ) * b + a
  print( y - x + 1 )


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string s; cin>>s;
    int x=0;
    for(int i=0;i<3;i++) if(s[i]=='R') x++;
    if(s[1]=='R' || x==0) cout<<x<<endl;
    else cout<<1<<endl;

}

Measured memory_bytes: 3628
import java.util.Scanner;

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

	        StringBuilder strAfter = new StringBuilder();
			for(int i=0; i<str.length(); i++) {
				 strAfter.append("x");
			}

          	System.out.print(strAfter);
    }
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int p = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'p'){
			p++;
		}
	}
	printf("%d\n", s.size() / 2 - p);
	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>

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

  bool ans = true;

  for (int i=0; i<N; i++) {
    int A;
    std::cin >> A;

    if (A % 2 == 0) {
      if (A % 3 == 0) {
        continue;
      }
      if (A % 5 == 0) {
        continue;
      }
      ans = false;
      break;
    }
  }

  std::cout << (ans ? "APPROVED" : "DENIED") << std::endl;

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let ab = read_vec::<usize>();
    if (ab[0] + ab[1]) % 2 == 0 {
        println!("{}", (ab[0] + ab[1]) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		for(int i=0;i<n;i++) {
			v[i]=sc.nextInt();
		}
		
		Arrays.sort(v);
		double ans=(v[0]+v[1])/2.0;
		for(int i=2;i<n;i++) {
			ans = (ans+v[i])/2.0;
		}
		
		System.out.println(ans);
		
	}
		


}


Measured memory_bytes: 21844
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque 

class Edge:
    def __init__(self, to, id):
        self.to = to
        self.id = id

def main():
    
    n = int(readline())
    g = [[] for _ in range(n)]

    for i in range(n-1):
        a, b = map(int, readline().split())
        g[a-1].append(Edge(b-1, i))
        g[b-1].append(Edge(a-1, i))

    dq = deque()    
    done = [0 for _ in range(n)]
    dq.append(0)
    done[0] = 1
    edgecolor = [0 for _ in range(n-1)]

    while len(dq) > 0: 
        v = dq.pop()
        c = -1
        for e in g[v]:
            nx = e.to
            edge_id = e.id
            if done[nx]:
                c = edgecolor[edge_id]
        k = 1
        for e in g[v]:
            nx = e.to
            edge_id = e.id
            if done[nx]:
                continue
            if k == c:
                k += 1
            edgecolor[edge_id] = k
            k += 1  
            done[nx] = 1
            dq.append(nx)

    mx = max(edgecolor) 
    print(mx)
    for ec in edgecolor:
        print(ec)

if __name__ == '__main__':
    main()


Measured memory_bytes: 82080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
/* 
https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
ll n , k ;
cin >> n >> k ;
COMinit();
vector<ll> fac = factorial(100000);
// 1
//cout << mypow(k,n) << endl;

//2
cout << (COM(k,n)*fac[n])%mo << endl;
return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int i = 0;
        for (int x = a; x <= b; x++) {
        		if (c%x == 0) i++;
        }
        System.out.println(i);
    }
}


Measured memory_bytes: 26308
import sys
input = sys.stdin.readline

def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])

    t = []
    for a,b in tmp:
        t+=[b]*a
        
        if len(t) >=N:
            break

    A = A+ t
    A.sort(reverse = 1)
    print(sum(A[:N]))

if __name__ == '__main__':
    sol()


Measured memory_bytes: 36544
// ACPC_AIZUDAI_DROPOUT
// coder : naan

#include <bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned long MOD = 998244353, percent = 828542813;
    const auto f = [&MOD](unsigned long a){
        unsigned long ret = 1, n = MOD - 2;
        while(n){
            if(n & 1)(ret *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return ret;
    };
    unsigned long N, K, A;
    cin >> N >> K >> A;
    (A *= percent) %= MOD;
    unsigned long M = N + K + 1, Ninv = f(N);
    vector<unsigned long> dp(M), sum(M);
    fill(dp.begin(), dp.end(), 1);
    partial_sum(dp.begin(), dp.end(), sum.begin());
    for(unsigned long i = N + 1; i < M; ++i){
        dp[i] = (A * (sum[i - 1] + MOD - sum[i - N - 1]) % MOD) * Ninv % MOD;
        sum[i] = (sum[i - 1] + dp[i]) % MOD;
    }
    cout << (dp.back() * f(A)) % MOD << endl;
    return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
 
typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
int main() {

    int n;
    cin >> n;

    int ans = 0;

    int x[n];
    rep(i, n) {
        cin >> x[i];
    }

    for (int i = 1; i <= 100; i++) {

        int sum = 0;

        rep (j, n) {
            sum += (i - x[j]) * (i - x[j]);
        }

        if (i == 1)
            ans = sum;

        ans = min(ans, sum);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
using namespace std;

#define int int64_t
#define pb push_back
#define pbb pop_back
#define pf pop_front
#define pff push_front
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 5e5, MOD = 1e9 + 7;
const ld EPS = 1e-9, PI = acos(-1);

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];

    int ans_a = 0, ans_b = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i])
            ans_a += (b[i] - a[i]) / 2;
        else
            ans_b += a[i] - b[i];
    }

    cout << (ans_a >= ans_b ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s,t,u;
  cin>>s>>t>>u;
  printf("%c%c%c\n",s[0]+'A'-'a',t[0]+'A'-'a',u[0]+'A'-'a');
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  set<P> E;
  V x(n);
  rep(i, n) {
    int s, t;
    cin >> s >> t >> x[i];
    E.emplace(s-x[i], i);
    E.emplace(t-x[i], i);
  }

  set<P> S;
  rep(_, q) {
    int d; cin >> d;
    while ((!E.empty()) && (*E.begin()).first <= d) {
      int i = (*E.begin()).second;
      E.erase(E.begin());
      auto p = P({x[i], i});
      if (S.find(p) == S.end()) S.insert(p);
      else S.erase(p);
    }
    if (S.empty()) cout << -1 << "\n";
    else cout << (*S.begin()).first << "\n";
  }
  return 0;
}


Measured memory_bytes: 22692
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int max = 0;
        for (int i = 0; i < S.length()-T.length()+1; i++) {
            String now = S.substring(i, i+T.length());
            int count = 0;
            for (int j = 0; j < T.length(); j++) {
                if (T.charAt(j) == now.charAt(j)) {
                    count++;
                }
            }
            max = Math.max(max, count);
        }
        System.out.println(T.length()-max);
    }
}


Measured memory_bytes: 36600
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
//	cout<<y<<m<<d;
	if(y>2019)
		cout<<"TBD"<<endl;
	else if(y == 2019){
		if(m>4)
			cout<<"TBD"<<endl;
		else if(m == 4){
			if(d > 30)
				cout<<"TBD"<<endl;
			else
				cout<<"Heisei"<<endl;
		}
		else{
			cout<<"Heisei"<<endl;
		}
	}
	else{
		cout<<"Heisei"<<endl;
	}
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main()
{
    FAST;
   int x;
   cin>>x;
   if(x==0)
   {
       cout<<"1"<<endl;
   }
   else
   {
        cout<<"0"<<endl;
   }


    return 0;
}










Measured memory_bytes: 3596
A, B, K = map(int, input().rstrip().split())
N = abs(A-B) + 1
if N//2 < K:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)
    

Measured memory_bytes: 3060
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n)
	{
		cin >> p[i];
	}

	int ans = 0;
	rep(i, n - 2)
	{
		auto l = { p[i], p[i + 1], p[i + 2] };
		if (p[i + 1] != std::min(l) && p[i + 1] != std::max(l))
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
using tii = tuple<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
//#define INF (ll)1E9
#define INF INT_MAX
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

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

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vi a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vvi dp(401, vi(401, INF));
	dp[0][0] = 0;
	rep(k,n){
		for(int i=400;i>=0;i--){
			for (int j = 400; j >= 0; j--) {
				if (dp[i][j] != INF) {
					dp[i + a[k]][j + b[k]] = min(dp[i][j] + c[k], dp[i + a[k]][j + b[k]]);
				}
			}
		}
	}
	int ans = INF;
	rep(i, 401) {
		rep(j, 401) {
			if (i*j!=0&&i*mb==j*ma) {
				ans = min(ans,dp[i][j]);
			}
		}
	}
	cout << ((ans != INF) ? ans : -1) << endl;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int h,w,answer;
char s[50][50];
bool f[50][50];

void fin(int T, int Y){
 if(0 <= T && T < h && 0 <= Y && Y < w){
  if(s[T+1][Y]=='#'|| s[T-1][Y]=='#' || s[T][Y+1]=='#' || s[T][Y-1]=='#') f[T][Y] = false;
	}
 }
int main(){
 cin >> h >> w;
 for(int i = 0; i < h; i++){
  for(int j = 0; j < w; j++){
	 cin >> s[i][j];
	 if(s[i][j] == '#') f[i][j] = true;
	}
 }

 for(int i = 0; i < h; i++){
  for(int j = 0; j < w; j++){
	 if(s[i][j] == '#')fin(i,j);
	}
 }

 for(int i = 0; i < h; i++){
  for(int j = 0; j < w; j++){
	 if(f[i][j]){answer++;}
	}
 }

 if(answer) cout << "No" << endl;
 else cout << "Yes" << endl;
 return 0; 
};


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int W,N,ansap,answp,a,b,c=0,nw;
int dp[1001][1001];
int ap[1001];
int wp[1001];
char mj [5];


int main(){
  char ch;
  while(true){
    c++;
    cin>>W;
    if(W==0)break;
    cin>>N;
    for(int i=1;i<=N;i++){
      cin>>ap[i];
      cin >> ch;
      cin>>wp[i];
    }
    
    for(int i=0;i<1001;i++){
      dp[0][i]=0;
      dp[i][0]=0;
    }
    
    for(int i=1;i<=N;i++){
      for(int j=1;j<=W;j++){
	nw=j-wp[i];
	if(nw>=0){
	  if(dp[i-1][j]<dp[i-1][nw]+ap[i]){
	    dp[i][j]=dp[i-1][nw]+ap[i];
	  }else{
	    dp[i][j]=dp[i-1][j];
	  }
	}else{
	  dp[i][j]=dp[i-1][j];
	}
      }
    }
    ansap=0;
    for(int i=1;i<=W;i++){
      if(ansap<dp[N][i]){
	ansap=dp[N][i];
	answp=i;
      }
    }
    


    cout<<"Case "<<c<<":"<<endl;
    cout<<ansap<<endl;
    cout<<answp<<endl;
  }
  return 0;
}

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

int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    cout << a << " " << b << " " << c << endl;
}


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

int main(){
  int n,y;
  while(1){
    cin >> n;
    if(n==0) break;
    cin >>y;
    double rmax=0,bmax=0;
    for(int k=0;k<n;k++){
      int b,t;
      double r;
      cin >> b>>r>>t;
      if(t==1){
	if(rmax<(1+y*r/100)) rmax=(1+y*r/100),bmax=b;
      }
      if(t==2){
	double rn=pow(1+r/100,y);
	if(rmax<rn) rmax=rn,bmax=b;
      }
    }
    cout << bmax<<endl;
  }

  return 0;
}

Measured memory_bytes: 1288
#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;

int a, b = 0, n, k;
string s, t;
int main()
{
	cin >> n;
	rep(i, 9)
	{
		rep(j, 9)
			if (n == (i + 1) * (j + 1))
			{
				s = "Yes"; break;
			}
		if (s == "Yes")
			break;

	}
	if (s == "Yes")
		cout << s << endl;
	else
		cout << "No" << endl;
}

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

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	public void run() {
		int n = in.nextInt(), m = in.nextInt();
		int[] array = new int[n+1];
		
		for (int i = 0; i < m; i++) {
			int c = in.nextInt(), d = in.nextInt();
			for (int j = c; j < d; j++) {
				array[j] = 1;
			}
		}
		
		int cnt = 0;
		for (int i = 0; i < n; i++)
			if (array[i] == 1) cnt++;
		
		System.out.println(cnt * 2 + n + 1);
		
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 20256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, m, q;
int u[100010];
int ans[100010];

vi G[100010];

void color( int v , int d , int c ){
  queue<pi> que;
  if( u[v] == -1 ){
    ans[v] = c;
  }
  if( u[v] < d ){
    u[v] = d;
    if( d > 0 ){
      que.emplace( v , d );
    }
  }
  while( not que.empty() ){
    int x = que.front().fi;
    int r = que.front().se - 1;
    que.pop();
    YYS( w , G[x] ){
      if( u[w] == -1 ){
        ans[w] = c;
      }
      if( u[w] < r ){
        u[w] = r;
        if( r > 0 ){
          que.emplace( w , r );
        }
      }
    }
  }
}

int v[100010];
int d[100010];
int c[100010];

int main(){

  n = in();
  m = in();
  REP( i , m ){
    int a = in() - 1;
    int b = in() - 1;
    G[a].pb( b );
    G[b].pb( a );
  }

  REP( i , n ){
    u[i] = -1;
  }
  
  q = in();
  REP( i , q ){
    v[i] = in() - 1;
    d[i] = in();
    c[i] = in();
  }
  for( int i = q-1; i >= 0; i-- ){
    color( v[i] , d[i] , c[i] );
  }
  
  REP( i , n ){
    printf( "%d\n" , ans[i] );
  }

  return 0;
}


Measured memory_bytes: 8912