akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    string in;
    rep(i,n)in=(char)(i+49)+in;

    rep(i,m){
      int a,b;
      cin>>a>>b;
      //cout<<in<<endl;
      in=in.substr(a-1,b)+in.substr(0,a-1)+in.substr(a+b-1);
    }
    cout<<in[0]-'0'<<endl;
  }

}

Measured memory_bytes: 1212
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 23:58:34 2020

@author: Kanaru Sato
"""

N=int(input())
X=list(map(int, input().split()))
Pvalues=[]

for P in range(1,101):
    Pvalue = 0
    for i in range(0,N):
        Pvalue += (X[i]-P)**2
    Pvalues.append(Pvalue)

print(min(Pvalues))

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

bool ArrayDiff(int[], int[], int);

using namespace std;

int main () {

    int N, X, Y;
    cin >> N;

    int TArray[N], XArray[N], YArray[N];

    for (int i = 0; i < N; i++) {
        cin >> XArray[i];
        TArray[i] = i + 1;
    }

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

    int i = 0;
    X = Y = -1;
    do{
        if (ArrayDiff(TArray, XArray, N)){
            X = i;
        }
        if (ArrayDiff(TArray, YArray, N)) {
            Y = i;
        }
        if (X >= 0 && Y >= 0) {
            break;
        }

        i++;
    }while ( next_permutation(TArray, TArray + N) );

    //cout << X << ' ' << Y << endl;

    X -= Y;

    if ( X < 0 ) {
        X *= -1;
    }

    cout << X << endl;

    return 0;
}

bool ArrayDiff(int a[], int b[], int N) {
    bool flag = true;

    for ( int i = 0; i < N; i++ ) {
        //cout << '@' << a[i] << '=' << b[i] << endl;
        if (a[i] != b[i]) {
            flag = false;
            break;
        }
    }

    return flag;
}

Measured memory_bytes: 256
import math


class Solution:
    def solve(self, a: int, b: int, x: int) -> float:

        def vol(theta: float) -> float:
            t = math.tan(theta)

            if t > a/b:
                return (a**2)*b - (a**3)/2/t
            else:
                return a*(b**2)*t/2

        # almost full
        if abs(a*a*b - x) < 1e-8:
            return 0

        thetaLeft = 0
        thetaRight = math.pi/2 - 1e-8

        for i in range(100):
            thetaCenter = (thetaLeft + thetaRight)/2
            if vol(thetaCenter) < x:
                thetaLeft = thetaCenter
            else:
                thetaRight = thetaCenter

        return 90 - thetaLeft * 180 / math.pi


if __name__ == '__main__':

    # standard input
    a, b, x = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b, x))

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0)"Possible" else "Impossible")
}



Measured memory_bytes: 31400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
 
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,arr[10];
ll func(ll idx,ll na,ll nb,ll nc){
    if(idx==n+1){
        if(na==0 || nb==0 || nc==0)return 1e9;
        ll val = abs(a-na) + abs(b-nb) + abs(c-nc);
        return val;
    }
    ll ans = 1e9;
    ans = min(ans , func(idx+1,na,nb,nc) );

    if(na==0)ans=min(ans , func(idx+1,na+arr[idx],nb,nc));
    else ans = min(ans , func(idx+1,na+arr[idx],nb,nc) + 10 );

    if(nb==0)ans=min(ans , func(idx+1,na,nb+arr[idx],nc));
    else ans = min(ans , func(idx+1,na,nb+arr[idx],nc) + 10 );

    if(nc==0)ans=min(ans , func(idx+1,na,nb,nc+arr[idx]));
    else ans = min(ans , func(idx+1,na,nb,nc+arr[idx]) + 10 );

    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>a>>b>>c;
    for(ll i=1;i<=n;i++)cin>>arr[i];
    cout<<func(1,0,0,0);
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#define REP(i,m,n)	for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n)	REP(i,0,n)

using namespace std;

int ans, cnt1;

int main() {
	int n, d;	cin >> n >> d;
	int x[10][10];
	rep(i, n){
		rep(j, d){
			cin >> x[i][j];
		}
	}


	rep(i, n) {
		REP(j, i + 1, n) {
			rep(k, d){
				cnt1 += pow(x[i][k] - x[j][k], 2);
			}
			for (int i = 0; i*i <= cnt1; i++){
				if (i*i == cnt1){ ans++; }
			}
			cnt1 = 0;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char str[5];
  char a,b,c,d;
  scanf("%s",str);
	a=str[0],b=str[1],c=str[2],d=str[3];
	if((a==b && c==d && a!=c)|| (a==c && b==d && a!=b)||(a==d && b==c && a!=b))printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readIntLine(n int) []int {
	list := make([]int, n)
	for i := 0; i < n; i++ {
		list[i] = readInt()
	}
	return list
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := readIntLine(n)
	b := readIntLine(n)
	c := readIntLine(n)
	sort.Ints(a)
	sort.Ints(c)

	ans := 0
	for i := 0; i < n; i++ {
		_, ra := lowerBound(b[i], a)
		_, rc := upperBound(b[i], c)
		ans += ra * (n - rc)
	}
	fmt.Println(ans)
}

func lowerBound(target int, list []int) (int, int) {
	l := -1
	r := len(list)
	for r-l > 1 {
		m := (l + r) / 2
		if target <= list[m] {
			r = m
		} else {
			l = m
		}
	}
	return l, r
}

func upperBound(target int, list []int) (int, int) {
	l := -1
	r := len(list)
	for r-l > 1 {
		m := (l + r) / 2
		if target < list[m] {
			r = m
		} else {
			l = m
		}
	}
	return l, r
}


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

int main(){
  int n;
  cin >> n;
  int a[9]={};
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    a[min(x/400,8)]++;
    if(x/400<8)a[x/400]=1;
  }
  int cnt=0;
  int ret = accumulate(a,a+8,0);
  if(ret==0){
    cout << min(1,a[8]) << " " << a[8] << endl;
  }else{
    cout << ret << " " << ret + a[8] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << r*r << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
//#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

char a[500][500];
int dp[500][500];
int n,m;
void upd(int &x,int y){
    if(x>y)x=y;
}
signed main(){
   
    cin>>n>>m;
    rep(i,1,n)rep(j,1,m)cin>>a[i][j];
    memset(dp,0x3f,sizeof dp);
    dp[0][1]=0;
    rep(i,1,n){
        rep(j,1,m){
            if(a[i][j]=='#'){
                upd(dp[i][j],dp[i-1][j] + 1 - (a[i-1][j] == '#'));
                upd(dp[i][j],dp[i][j-1] + 1 - (a[i][j-1] == '#'));
            }
            else {
                upd(dp[i][j],dp[i-1][j]);
                upd(dp[i][j],dp[i][j-1]);
            }
        }
    }
    cout<<dp[n][m]<<endl;


    getchar();getchar();

}


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

namespace AtCoder.ABC
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sDash = Console.ReadLine();
            var sDashArray = sDash.ToArray();
            var t = Console.ReadLine();

            var index = -1;

            for (int i = sDash.Length - t.Length; i >= 0; i--) {
                var can = false;
                for (int j = 0; j < t.Length; j++) {
                    if (sDash[j + i] != '?') {
                        if(sDash[j + i] != t[j]) {
                            break;
                        }
                    }

                    if(j == t.Length - 1) {
                        can = true;
                    }
                }

                if (can) {
                    index = i;
                    break;
                }
            }

            if(index == -1) {
                Console.WriteLine("UNRESTORABLE");
                return;
            }

            for(int i = 0; i < t.Length; i++) {
                sDashArray[index + i] = t[i];
            }

            for(int i = 0; i < sDash.Length; i++) {
                if(sDashArray[i] == '?') {
                    Console.Write("a");
                } else {
                    Console.Write(sDashArray[i]);
                }
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 26244
N = int(input())
E = [[] for _ in range(N)]
for i in range(N - 1):
	a, b = map(int, input().split())
	E[a - 1].append(b - 1)
	E[b - 1].append(a - 1)


def farthest(s):
	visited = [False] * N
	stack = [(s, 0)]
	best = s, 0
	while stack:
		i, d = stack.pop()
		visited[i] = True
		if best[1] < d:
			best = i, d
		stack.extend((v, d + 1) for v in E[i] if not visited[v])
	return best

print('First' if (farthest(farthest(0)[0])[1] % 3 != 1) else 'Second')


Measured memory_bytes: 56752
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N =20000;
enum{UNDEFINED=-1,HEAD=0,TAIL=1};
class st{
public:
  int data[2];
  
};
struct Edge{int t,type;};
class tri{
public:
  int ind,x,y,type;
  bool operator<(const tri & a)const{
    if (x != a.x)return x < a.x;
    return y < a.y;
  }
};

bool vis[N];
st in[N];
vector<Edge> edge[N][2];

bool search(int now,int type,int which){
  if (vis[now]){
    return in[now].data[type] == which;
  }
  vis[now]=true;
  in[now].data[type]=which;
  in[now].data[1-type]=1-which;
  //cout << "ch " << now <<" " << type <<" " << which << endl;
  //cout << now <<" " << in[now].data[0]<<" " << in[now].data[1] << endl;
  rep(i,2){
    rep(j,(int)edge[now][i].size()){
      if (!search(edge[now][i][j].t,edge[now][i][j].type,i == type?which:1-which))return false;
    }
  }
  return true;
}

bool solve(int n){
  rep(i,n)vis[i]=false;
  rep(i,n){
    if (!vis[i]){
      if (!search(i,HEAD,HEAD))return false;
    }
  }
  return true;
}

int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
void makeedge(int ind,int x,int y,int type,set<tri> &S){
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    set<tri>::iterator itr = S.find((tri){-1,nex,ney,-1});
    if (itr == S.end())continue;
    edge[ind][type].push_back((Edge){(*itr).ind,(*itr).type});
    edge[(*itr).ind][(*itr).type].push_back((Edge){ind,type});
  }
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n){
      edge[i][0].clear(),edge[i][1].clear();
      in[i].data[0]=in[i].data[1]=UNDEFINED;
    }
    set<tri> S;
    rep(i,n){
      int y,x;char c;
      cin>>x>>y>>c;
      makeedge(i,x,y,HEAD,S);
      if (c == 'x')makeedge(i,x+1,y,TAIL,S);
      else makeedge(i,x,y+1,TAIL,S);
      S.insert((tri){i,x,y,HEAD});
      if (c == 'x')S.insert((tri){i,x+1,y,TAIL});
      else         S.insert((tri){i,x,y+1,TAIL});
    }
    /*
    rep(i,n){
      cout <<"info " << i << endl;
      cout <<"0" << endl;
      rep(j,edge[i][0].size())
	cout << edge[i][0][j].t <<" " << edge[i][0][j].type << endl;
      cout <<"1"<<endl;
      rep(j,edge[i][1].size())
	cout << edge[i][1][j].t <<" " << edge[i][1][j].type << endl;
	}
    */

    if (solve(n))cout <<"Yes" << endl;
    else cout <<"No" << endl;
  }
}

Measured memory_bytes: 4432
#include <iostream>

using namespace std;

int i,j,n;
string str;

int main(){
  cin >> n;
  cin >> str;
  long long ans = 0,siro = 0;
  j = 0;
  for(i = 0;i < n;i++){
    if(str[i] == '.'){
      siro++;
      j++;
      if(j > ans) ans = j;
    }
    else{
      j--;
    }
  }
  cout << siro-ans << endl;
}


Measured memory_bytes: 640
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
void Restricted(){
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << (a + b) << endl;
	}

}

int main() {
	Restricted();
	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 str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		int k = Integer.parseInt(br.readLine());

		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			int count = 0;
			for (int i = 0; i < k; i++) {
				if (a < b) {
					break;
				}
				b *= 2;
				if (k <= 0) {
					break;
				}
				count = i + 1;
			}
			if (a < b && b < c) {
				System.out.println("Yes");
			} else {
				k -= count;
				for (int i = 0; i < k; i++) {
					if (b < c) {
						break;
					}
					c *= 2;
					if (k <= 0) {
						break;
					}
				}
				if (a < b && b < c) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
	}
}

Measured memory_bytes: 32576
#include <iostream>

using namespace std;

int main(){
  int A, B, tmp, ans=0;
  cin >> A >> B;
  if(B > A){
    tmp = A; A = B; B = tmp;
  }
  ans += A; A--;
  if(B > A){
    tmp = A; A = B; B = tmp;
  }
  ans += A;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	cin >> n;
	int f = 0;
	int c = 0;
	for(int i = 0; i < n; ++i){
		int a;
		scanf("%d", &a);
		if(a >= 3200){ ++c; }
		else{ f |= 1 << (a / 400); }
	}
	int t = __builtin_popcount(f);
	printf("%d %d\n", max(t, 1), t + c);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    BigDecimal A = new BigDecimal(S[0]);
    BigDecimal B = new BigDecimal(S[1]);
    System.out.println(A.multiply(B).longValue());
  }
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<cutup(n,x)*t<<endl;
}

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

int main(){
	char a;
	while(true) {
		a = cin.get();
		if ( a>='A' && a<='Z' ) {
			a+='a'-'A';
		}else if ( a>='a' && a<='z' ) {
			a+='A'-'a';
		}
		cout << a;
		if ( a == '\n' ) break;
	}
    return 0;
}

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

ll b[100];
int main() {
   ll i,j,k;
    ll n,sum=0;
    cin >>n ;
    for(i=0; i<n; i++)
    {
      cin >> b[i];
    }

    for(i=0; i<n; i++)
    {
      for(j=i+1; j<n; j++)
      {
        sum+=b[i]*b[j];
      }
    }
  cout << sum << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll h;
	ll k;
	string s, t;
	//char c;
	ll c;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> l >> r >> d;

	for (ll i = l; i <= r; i++) {
		if (i % d == 0) {
			l_ans++;
		}
	}

	cout << l_ans << "\n";

	return;
}


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

	solve_abc_a();

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long double money=0;
  long double x[N+1];
  string u[N+1];
  for(int i=0; i<N; i++){
    cin >> x[i] >> u[i];
  }
  for(int i=0; i<N; i++){
    if(u[i] == "JPY")
      money += x[i];
    else
      money += x[i]*380000.0;
  }
  cout << money << endl;
  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	int l = 0, r = 1000000001;
	while (abs(r - l) > 1) {
		int mid = (l + r) / 2;
		int cnt = 0;
		rep(i, n) {
			cnt += (a[i] + mid - 1) / mid - 1;
		}
		if (cnt <= k)r = mid;
		else l = mid;
	}
	printf("%d\n", r);

	Please AC;
}


Measured memory_bytes: 4048
package main

import (
	"fmt"
	// "strings"
)

func main() {

	var str string
	fmt.Scan(&str)

	var sum int64
	for _, v := range str {

		sum += int64(v) - '0'
	}

	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 3184
S=input()
list=[]
for i in S:
    list.append(i)
num_for=int(list[0]+list[1])
num_lat=int(list[2]+list[3])

def yymm_jud(x):
    if 0<x<13:
        return 1
    else:
        return 0
def mmyy_jud(x):
    if 0<x<13:
        return 1
    else:
        return 0

if yymm_jud(num_lat)==1 and mmyy_jud(num_for)==0:
    print("YYMM")
elif yymm_jud(num_lat)==0 and mmyy_jud(num_for)==1:
    print("MMYY")
elif yymm_jud(num_lat)==0 and mmyy_jud(num_for)==0:
    print("NA")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end

  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end

  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (h, a) = InputLine.to_ia

  c = h / a
  c += 1 if h % a > 0

  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

int main(){

	int N,T,E;
	vector<int> ti;
	int x;

	cin>>N>>T>>E;

	for(int i=0;i<N;i++){
		cin>>x;
		ti.push_back(x);
	}

	for(int i=T-E;i<=T+E;i++){
		for(int j=0;j<ti.size();j++){
			if(i%ti[j]==0){
				cout<<j+1<<endl;
				return 0;
			}
		}
	}

	cout<<"-1"<<endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int w,h,n;cin>>w>>h>>n;
   int xleft=0,xright=w,ydown=0,yup=h;
   for(int i=0,x,y,a;i<n;++i)
   {
     cin>>x>>y>>a;
     if(a==1)
     {
        xleft=max(xleft,x);
     }
     else if(a==2)
     {
       xright=min(xright,x);
     }
     else if(a==3)
     {
        ydown=max(ydown,y);
     }
     else if(a==4)
     {
       yup=min(yup,y);
     }
   }
   if(xright<xleft||yup<ydown)
    cout<<0<<endl;
   else
   cout<<(xright-xleft)*(yup-ydown)<<endl;
   
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    ll ans = ( 1900*M + (N-M)*100 ) * pow(2,M);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a, b, c, d, e]
dish_max = []
min_num = 10
min_index = -1
for i in range(len(dish)):
  if (dish[i]-1)%10<min_num:
    min_num = (dish[i]-1)%10
    min_index = i
  else:
    None
#print(min_index, min_num)
time = 0
for i in range(len(dish)):
  if i!=min_index:
    if dish[i]%10!=0:
      time += int(dish[i]/10)*10+10
    else:
      time += dish[i]
  else:
    time += dish[i]
print(time)

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

const int MOD = 1e9+7;

int A[1111];

map<int,bool> ap;

int main () {
    int N;
    scanf("%d",&N);
    for (int i=1;i<=N;i++) {
        scanf("%d",&A[i]);
    }
    for (int i=1;i<=N;i++) {
        long long hs=0;
        for (int j=i;j<=N;j++) {
            hs=(hs*10+A[j])%MOD;
            ap[hs]=true;
            //cerr<<"::"<<hs<<endl;
        }
    }
    int p=0;
    while (ap[p]) p++;
    cout<<p<<endl;
}

Measured memory_bytes: 24784
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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; }
const long long INF = 1LL << 60;

vector<vector<ll>> dp(110000, vector<ll>(3, 0));

int main(){
  int N;
  cin >> N;
  vector<vector<ll>> a(N, vector<ll>(3));
  for(int i = 0; i < N; i++){
    cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
  }

  dp.at(0) = {0, 0, 0};

  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(j == k) continue;
        chmax(dp.at(i+1).at(j), dp.at(i).at(k) + a.at(i).at(j));
      }
    }
  }
  cout << max(dp.at(N).at(0), max(dp.at(N).at(1), dp.at(N).at(2))) << endl;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
#include<cstring>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int           long long
#define umapii        unordered_map<int,int>
#define ps(x,y)       fixed<<setprecision(y)<<x // sets precision upto required digits
#define arr(a,n)      int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define outarr(a,n)   for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define mod           1000000007
#define ff            first
#define big           1e15
#define ss            second
#define add           push_back
#define remove        pop_back
#define mapii         map<int,int>
#define large         *max_element
#define small         *min_element
#define pqi           priority_queue<int>
#define mpqi          priority_queue<int,vector<int>,greater<int>>
#define in(n)         int n;cin>>n;
#define w(t)          int t;cin>>t;while(t--)
#define vi            vector<int>
#define vivi          vector<vector<int>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;



int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output3.txt", "w", stdout);
#endif

    int a;
    double b;
    cin >> a >> b;
    int x = b * 100 + 0.5;
    a = a * x;
    a = a / 100;
    cout << a << endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int a,b,c;

void solve(){
  int t=0,now=0;
  bool ok=false;
  while(1){
    if(now>=100000)break;
    if(now<=60*t+c&&60*t+c<=now+a){
      cout<<60*t+c<<endl;
      ok=true;break;
    }else if(now<=60*t+c){
      now+=(a+b);
    }else{
      t++;
    }
  }
  if(!ok)cout<<-1<<endl;
}

int main(){
  cin>>a>>b>>c;
  solve();
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
double A[301][301][301];
int N;
double f(int i, int j, int k)
{
    if (i == 0 && j == 0 && k == 0) return 0;
    if (i < 0 || j < 0 || k < 0) return 0;
    if (A[i][j][k] > 0) return A[i][j][k];
    double ans = i * f(i-1, j+1, k) + j * f(i, j-1, k+1) + k * f(i, j, k-1) + N;
    ans /= i + j + k;
    return A[i][j][k] = ans;
}
int main()
{
    cin >> N;
    int i, j, k;
    for (i = 0; i < 301; i++) for (j = 0; j < 301; j++) for (k = 0; k < 301; k++) A[i][j][k] = -1;
    A[0][0][0] = 0;
    i = j = k = 0;
    for (int s = 0; s < N; s++) {
        int a; cin >> a;
        if (a == 3) i++;
        if (a == 2) j++;
        if (a == 1) k++;
    }
    cout << fixed << setprecision(16) << f(i, j, k) << endl;
    return 0;
}

Measured memory_bytes: 213376
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

constexpr int N = 8;

std::pair<int, vvec<bool>> solve(vvec<bool> map, int y, int x, int queenCount, vec<bool> h, vec<bool> w, vec<bool> tr, vec<bool> br)
{
    ++queenCount;

    map[y][x] = true;
    h[y] = true;
    w[x] = true;
    tr[y + x] = true;
    br[7 - y + x] = true;

    if (queenCount == N)
    {
        return make_pair(queenCount, map);
    }

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
        {
            if (!h[i] && !w[j] && !tr[i + j] && !br[7 - i + j])
            {

                auto m = solve(map, i, j, queenCount, h, w, tr, br);

                if (m.first == N)
                {
                    queenCount = N;
                    map = m.second;
                    goto LOOP_END;
                }
            }
        }

    LOOP_END:

    return make_pair(queenCount, map);
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    string s;
    for (int i = 0; i < 3; ++i)
    {
        string line;
        getline(cin, line);
        s += line;
    }

    string r;
    remove_copy(s.cbegin(), s.cend(), back_inserter(r), ' ');

    set<ll> used;

    queue<pair<int, string>> q;
    q.push(make_pair(0, r));

    const string target = "123456780";

    while (!q.empty())
    {
        auto current = q.front();
        q.pop();
        //cout << current.second << endl;

        if (used.count(stoll(current.second)) == 1)
            continue;
        used.emplace(stoll(current.second));

        if (current.second == target)
        {
            cout << current.first << endl;
            break;
        }

        for (int i = 0; i < 9; ++i)
            if (current.second[i] == '0')
            {
                auto r = i / 3;
                auto c = i % 3;
                for (int y = -1; y <= 1; ++y)
                    for (int x = -1; x <= 1; ++x)
                    {
                        if (abs(x) + abs(y) != 1)
                            continue;
                        if (r + y < 0 || r + y > 2 || c + x < 0 || c + x > 2)
                            continue;
                        auto next = current.second;
                        swap(next[i], next[(r + y) * 3 + c + x]);
                        q.push(make_pair(current.first + 1, next));
                    }
            }
    }

    return 0;
}


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

public class Main {

	static int[][] presumw, presumb;
	static int[] mapw, mapb;
	static int n;
	static long[][] dp;

	public static long dp(int w, int b) {

		if (w == n && b == n) {
			return 0;
		}
		if (dp[w][b] != -1)
			return dp[w][b];
		long ans = (long) 1e18;
		if (w != n) {
			ans = Math.min(ans, presumw[w + 1][mapw[w]] + presumb[b][mapw[w]] + dp(w + 1, b));
		}
		if (b != n) {
			ans = Math.min(ans, presumb[b + 1][mapb[b]] + presumw[w][mapb[b]] + dp(w, b + 1));
		}
		return dp[w][b] = ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		int[] v = new int[2 * n];
		char[] c = new char[2 * n];
		mapw = new int[n];
		mapb = new int[n];
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.next().charAt(0);
			v[i] = sc.nextInt() - 1;
			if (c[i] == 'W') {
				mapw[v[i]] = i;
			} else
				mapb[v[i]] = i;
		}
		presumw = new int[n + 1][2 * n];
		presumb = new int[n + 1][2 * n];
		for (int i = 0; i < 2 * n; i++) {
			if (c[i] == 'W')
				presumw[0][i] = 1;
			else
				presumb[0][i] = 1;
		}

		for (int i = 1; i < n + 1; i++) {
			for (int j = 0; j < 2 * n; j++) {
				presumw[i][j] = presumw[i - 1][j];
				presumb[i][j] = presumb[i - 1][j];
			}
			presumw[i][mapw[i - 1]] = 0;
			presumb[i][mapb[i - 1]] = 0;
		}
		for (int i = 0; i < n + 1; i++) {
			for (int j = 1; j < 2 * n; j++) {
				presumw[i][j] += presumw[i][j - 1];
				presumb[i][j] += presumb[i][j - 1];
			}
		}
		dp = new long[n + 1][n + 1];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		pw.println(dp(0, 0));
		pw.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		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 double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 134456
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    int p, q, r;
    cin >> p >> q >> r;

    cout << min({p+q, q+r, p+r}) << "\n";
}




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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t N, Q, tmp;
    cin >> N;
    vector<int> list(N);
    unordered_map<int, int> hist;
    int64_t sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        sum += tmp;
        list[i] = tmp;
        hist[tmp]++;
    }
    cin >> Q;
    int B, C;
    for (int i = 0; i < Q; i++)
    {
        cin >> B >> C;
        sum += hist[B] * (C - B);
        cout << sum << endl;
        hist[C] += hist[B];
        hist.erase(B);
    }
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li a,b,c,k;

    cin>>a>>b>>c>>k;

    while(k--)
    {
    	if(b<=a)
    	{
    		b*=2;
    	}
    	else if(c<=b)
    	{
    		c*=2;
    	}
    }

    cout<<((a<b && b<c) ? "Yes":"No");
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

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

    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

#define filename ""

int n;
int m;
int k;

int main () {
	cin >> n >> m >> k;
	for (int a = 0; a <= n; a++)
		for (int b = 0; b <= m; b++)
			if (n * m - a * b - (n - a) * (m - b) == k) {
				printf ("Yes\n");
				re 0;
			}
	printf ("No\n");
	return 0;
}


Measured memory_bytes: 256
n = input()
items = []
mw = 0
ms = 0
for _ in range(n):
    w, s, v = map(int, raw_input().split())
    items.append((-(s + w), s, w, v))
    ms = max(ms, s)
    mw = max(mw, w)
items.sort()

dp = [[0] * (mw + ms + 1) for _ in range(n)]
for i in range(items[n - 1][2], ms + mw + 1):
    dp[n - 1][i] = items[n - 1][3]
for i in range(n - 2, -1, -1):
    _, s, w, v = items[i]
    for j in range(1, mw + ms + 1):
        dp[i][j] = max(dp[i + 1][j], dp[i][j - 1])
        if 0 <= j - w <= s:
            dp[i][j] = max(dp[i][j], v + dp[i + 1][j - w])
print(max(dp[0]))


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

using namespace std;

int main(void) {
	int H,W;
	cin >> H >> W;
	vector<bool> row(H,true);
	vector<bool> col(W,true);
	vector< vector<char> > grid(H,vector<char>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> grid[i][j];
			if (grid[i][j] == '#') {
				row[i] = false;
				col[j] = false;
			}
		}
	}

	for (int i = 0; i < H; ++i) {
		bool op = false;
		for (int j = 0; j < W; ++j) {
			if (!row[i] && !col[j]) {
				cout << grid[i][j];
				op = true;
			}
		}
		if (op) {
			cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
s = input()

ans=0
if s[0]=='R' and s[1]=='R' and s[2]=='R':
    print(3)
elif s[1]=='R' and s[2]=='R':
    print(2)
elif s[0]=='R' and s[1]=='R':
    print(2)
elif s[0]=='R' or s[1]=='R' or s[2]=='R':
    print(1)
else:
    print(0)

Measured memory_bytes: 9052