akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int n , maxw;
    cin>>n>>maxw;
    
    ll weight[n];
    ll value[n];
    for(int i = 0;i<n;i++){
        cin>>weight[i];
        cin>>value[i];
    }
    
    int v = 0;
    for(int i = 0;i<n;i++) v+=value[i];
    
    vector<vector<ll>> dp(n+1,vector<ll>(v+1,INT_MAX));
    ll result = 0;
    dp[0][0]=0;
    for(int i = 1 ;i<=n;i++){
        for(int j = 0;j<=v;j++){
            //cout<<i<<" "<<j<<endl;
            
             if(j==0) dp[i][j] = 0;
            else if (value[i-1]<=j){
                dp[i][j] = min(weight[i-1] + dp[i-1][j-value[i-1]] , dp[i-1][j]);
            }
            else dp[i][j] = dp[i-1][j];
            
            if(dp[i][j]<=maxw){
            result = max(result, (ll)j);
        }
        }
    }
    
    
    cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000010

char* s[SIZE];
bool* visited[2][SIZE];

int main() {
  int H, W, K;
  int sx, sy, gx, gy;

  scanf("%d%d%d", &H, &W, &K);
  scanf("%d%d%d%d", &sy, &sx, &gy, &gx);
  sx--;
  sy--;
  gx--;
  gy--;

  for (int i = 0; i < H; i++) {
    s[i] = new char[W + 1];
    visited[0][i] = new bool[W + 1];
    visited[1][i] = new bool[W + 1];
    scanf("%s", s[i]);
  }

  priority_queue<pair<pair<pair<int, int>, int>, pair<int, int>>> pq; // {cost, dir}, {y, x}

  pq.push({{{0, 0}, 0}, {sy, sx}});

  while (pq.size()) {
    auto p = pq.top();
    pq.pop();

    auto cost = p.first.first;
    int dir = p.first.second;
    int y = p.second.first;
    int x = p.second.second;

    if (x < 0 || y < 0 || W <= x || H <= y) continue;
    if (s[y][x] == '@') continue;
    if (visited[dir][y][x]) continue;
    visited[dir][y][x] = true;

    debug(vector<int>({dir, y + 1, x + 1}));

    if (y == gy && x == gx) {
      printf("%d\n", -cost.first + (!!cost.second));
      return 0;
    }

    auto newCost = cost;
    newCost.second--;
    if (newCost.second == -K) {
      newCost.second = 0;
      newCost.first--;
    }

    if (dir == 0) {
      pq.push({{newCost, 0}, {y - 1, x}});
      pq.push({{newCost, 0}, {y + 1, x}});
    } else {
      pq.push({{newCost, 1}, {y, x - 1}});
      pq.push({{newCost, 1}, {y, x + 1}});
    }

    newCost = cost;
    newCost.first -= !!newCost.second;
    newCost.second = 0;

    pq.push({{newCost, !dir}, {y, x}});
  }

  puts("-1");

  return 0;
}


Measured memory_bytes: 10560
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second 
#define F0R(i, a) for (int i = 0;i < (a);++i)
#define FOR(i, a, b) for (int i = a; i < (b);++i)
#define FORd(i, a) for (int i = (a)- 1;i >= 0;--i)
#define F0Rd(i, a, b) for (int i = (a)- 1;i >= (a);--i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e9;

int main() {

	int N;
	cin>>N;
	int x = N%10;
	if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
		cout<<"hon"<<endl;
	}
	else if (x == 0 || x == 1 || x == 6 || x == 8) {
		cout<<"pon"<<endl;
	}
	else {
		cout<<"bon"<<endl;
	}

	return 0;
}


Measured memory_bytes: 3564
N,M = map(int,input().split())
LRD = [tuple(map(int,input().split())) for i in range(M)]

class WeightedUnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self.weight = [0] * N
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            pa = self.root(self.parent[a])
            self.weight[a] += self.weight[self.parent[a]]
            self.parent[a] = pa
            return pa
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b,w):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
            self.weight[ra] = w - self.weight[a] + self.weight[b]
        else:
            self.parent[rb] = ra
            self.weight[rb] = -w - self.weight[b] + self.weight[a]
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1
    def diff(self,a,b):
        return self.weight[a] - self.weight[b]

uf = WeightedUnionFind(N)
for l,r,d in LRD:
    l,r = l-1,r-1
    if uf.is_same(l,r):
        if uf.diff(l,r) != d:
            print('No')
            exit()
    else:
        uf.unite(l,r,d)
print('Yes')

Measured memory_bytes: 40820
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void solve() {
	int k; cin >> k; --k;
    cout << a[k] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000010
int c[N];
int main(void)
{
    int i, j, a, d, n;
    c[0]=c[1]=1;
    for(i=2;i*i<N;++i) if (!c[i])
        for(j=i*i;j<N;j+=i) c[j]=1;

    while (scanf("%d%d%d", &a, &d, &n), a) {
        for(i=!c[a];i<n;i+=!c[a]) a+=d;
        printf("%d\n", a);
    }
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    int n,ans,grey=0,brown=0,green=0,sky=0,blue=0,yellow=0,orange=0,red=0,super=0;
    int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int r;
        cin>>r;
        if(r<=399) grey++;
        else if(400<=r&&r<=799) brown++;
        else if(800<=r&&r<=1199) green++;
        else if(1200<=r&&r<=1599) sky++;
        else if(1600<=r&&r<=1999) blue++;
        else if(2000<=r&&r<=2399) yellow++;
        else if(2400<=r&&r<=2799) orange++;
        else if(2800<=r&&r<=3199) red++;
        else super++;
    }
    if(grey>=1) a=1;
    if(brown>=1) b=1;
    if(green>=1) c=1;
    if(sky>=1) d=1;
    if(blue>=1) e=1;
    if(yellow>=1) f=1;
    if(orange>=1) g=1;
    if(red>=1) h=1;
    if(a+b+c+d+e+f+g+h==0){
        ans=1;
    }else{
        ans=a+b+c+d+e+f+g+h;
    }
    cout<<ans<<" "<<a+b+c+d+e+f+g+h+super;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }

  for (int i = 0; i < H; i++) {
    int c_dot = 0;

    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '.') {
        c_dot++;
      }
    }

    if (c_dot == W) {
      for (int j = 0; j < W; j++) {
        a.at(i).at(j) = ' ';
      }
    }
  }

  for (int j = 0; j < W; j++) {
    int c_dot = 0;

    for (int i = 0; i < H; i++) {
      if (a.at(i).at(j) == '.' || a.at(i).at(j) == ' ') {
        c_dot++;
      }
    }

    if (c_dot == H) {
      for (int i = 0; i < H; i++) {
        a.at(i).at(j) = ' ';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    int c_space = 0;

    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == ' ') {
        c_space++;
      }
    }

    if (c_space == W) {
      continue;
    }

    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) != ' ') {
        cout << a.at(i).at(j);
      }
    }

    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<string>
#define lens 10000

using namespace std;
stack<pair<int, int> > S2;
stack<int> S1;
int a[lens];
int main()
{
	char c;
	int i = 0;
	int total = 0;
	while (cin >> c)
	{
		if (c == '\\')
		{
			S1.push(i);
			i++;
			int h = 0;
		}
		else if (c == '/')
		{
			if (S1.size() > 0)
			{
				int t = S1.top();
				S1.pop();
				int a = i - t;
				total += a;
				i++;
				while (S2.size() > 0 && S2.top().first > t)
				{
					int sum = S2.top().second;
					S2.pop();
					a = a + sum;
				}
				S2.push(make_pair(t, a));

			}
		}
		else if (c == '_')
		{
			if (S1.size() > 0)
				i++;
		}
		else if (c == '1')
		{
			break;
		}
	}
	cout << total << endl;
	cout << S2.size();
	int m = S2.size();
	for (int j = 0; j < m; j++)
	{
		a[j]=S2.top().second;
		S2.pop();
	}
	for (int j = m-1; j >= 0 ; j--)
	{
		cout << ' ';
		cout << a[j];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3164
N, M = map(int, input().split())
A = list(map(int, input().split()))

check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1

ans = N - x

if ans >= M :
    print('Yes')
else:
    print('No')

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

using namespace std;

int main() {

    int N;
    cin >> N;

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

    long long ans = 0;
    int MaxNum = 0;

    for (int i = 0; i < N; i++) {
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
        }

        cout << ans << endl;

    return 0;
    
    }

Measured memory_bytes: 4332
#include<stdio.h>
int main(void)
{
	int x,y,mini;
	scanf("%d%d",&x,&y);
	while((x!=0)||(y!=0))
	{
		
		if((x!=0)||(y!=0))
		{
			if(x>y)
			{
				mini=x;
				x=y;
				y=mini;
			}
			printf("%d %d\n",x,y);
			scanf("%d%d",&x,&y);
		}
	}
	return 0;
}



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

typedef complex<int> point;
typedef long long int lli;
typedef long double ld;
#define pii pair<int,int>
#define lasB(b) (b&(-b))
#define pld pair<ld,ld>
#define mod 1000000007
#define PI acos(-1.0)
#define PB push_back
#define N      555
#define EPS (1e-8)
#define ss substr
#define S second
#define IM image
#define F first
#define RE real
#define B begin
#define E end

int n;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string inp;
    cin>>inp;
    for(int i=0;i<3;i++)
    {
        if(inp[i]=='1')inp[i]='9';
        else if(inp[i]=='9')inp[i]='1';
    }
    cout<<inp;
    return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> v[300000];
	for (int i = 0; i < n; i++) {
		int m, c; cin >> m;
		while (m--) {
			cin >> c;
			v[i].push_back(c);
		}
	}
	priority_queue<int> pq;
	long long ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < v[i].size(); ++j) pq.push(v[i][j]);
		ans += pq.top(); pq.pop();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 19440
s = str(input()).replace("BC", "D")

def f(s):
  ans = 0
  add = 0
  for i in range(len(s)):
    if s[i] == "A":
      add += 1
    if s[i] == "D":
      ans += add
  return ans

ans = 0
j = 0
for i in range(1, len(s)):
  if s[i] == "B" or s[i] == "C":
    ans += f(s[j:i])
    j = i
ans += f(s[j:])

print(ans)

Measured memory_bytes: 43800
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int iin = sc.nextInt();
		TreeSet<Long> lia = new TreeSet<Long>();
		long iia = 0;
		for(int i=0;i<iin;i++){
			iia = sc.nextLong();
			if(lia.size()==0){
				lia.add(iia);
			}
			else{
				if(!lia.remove(iia)){
					lia.add(iia);
				}
			}
		}
		System.out.println(lia.size());
    }
}


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 1e6 + 6;
const int MOD = 1e9 + 7;
string s;
int dp[N][2];

int solve(int idx, int flag) {
    if (idx == SZ(s))return 1;
    int &ret = dp[idx][flag];
    if (~ret)return ret;
    ret = 0;
    loop(i, 2) {
        loop(j, 2) {
            if (i == 1 && j == 1)continue;
            if ((i + j) == (i ^ j) && (flag | (i + j) <= s[idx])) {
                ret += solve(idx + 1, (flag | (i + j) < s[idx]));
                if (ret >= MOD)ret -= MOD;
            }
        }
    }
    return ret;
}

int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    memset(dp, -1, sizeof dp);
    cin >> s;
    for (char &c : s)c -= '0';
    cout << solve(0, 0) << endl;


    return 0;
}


Measured memory_bytes: 16080
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		m=max(m,a[2]);
		
		int s = 10;
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
			if(m<=s)puts("YES");
			else puts("NO");
		}else{
			if(m<=s)puts("NO");
			else puts("YES");
		}
	}
}

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

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    int n = 0;
    private void solv() {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        int[][] us = new int[n+1][n+1];
        for (int i = 0; i < n; i++) {
            int u = input.nextInt();
            int k = input.nextInt();
            while (k-- > 0) {
                int v = input.nextInt();
                us[u][v] = 1;
            }
        }
        d = new int[n+1];
        f = new int[n+1];
        int t = 0;
        for (int i = 1; i <= n; i++) {
            t = calc(us, i, t);
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(String.format("%d %d %d", i, d[i], f[i]));
        }
    }
    int[] d;
    int[] f;
    int calc(int[][] us, int id, int t ) {
        if (d[id] != 0) return t;
        d[id] = ++t;
        for (int i = 1; i <= n; i++) {
            if (us[id][i] != 0) {
                t = calc(us, i, t);
            }
        }
        f[id] = ++t;
        return t;
    }
    
    void swap(int[] A, int x, int y) {
        int temp = A[x];
        A[x] = A[y];
        
        A[y] = temp;
    }
    
}

class Scanner {
    BufferedReader r;
    StreamTokenizer st;
    
    public Scanner(InputStream in) {
        r = new BufferedReader(new InputStreamReader(in));
        st = new StreamTokenizer(r);
    }
    
    public String next() {
        nextToken();
        return st.sval;
    }
    
    public Integer nextInt() {
        nextToken();
        return (int)st.nval;
    }
    
    private int nextToken() {
        int token = st.TT_EOF;
        try {
            token = st.nextToken();
        } catch (IOException e) {
        }
        return token;
    }
}

Measured memory_bytes: 19388
#include<iostream>
using namespace std;
int main(){
	long long x;
	cin >> x;
	long long ans=x/11*2;
	if(x-(ans*11/2)>6){
		ans+=2;
	}else if(x-(ans*11/2)>0){
		ans+=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AtCoderJapan
//
//  Created by macbook on 10/23/16.
//  Copyright © 2016 LiorCohen. All rights reserved.
//

#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    string s;
    cin >> s;
    
    char c = 'C',f = 'F';
    
    int pc = -1,pf = -1;
    pc = (int)s.find(c);
    if (pc != string::npos) {
        pf = (int) s.find(f, pc);
        if (pf != string::npos) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int k = sc.nextInt();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	if(a <= (b/k)*k) System.out.println("OK");
      	else System.out.println("NG");
    }
}

Measured memory_bytes: 35720
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int info[1001][4];
	int i;
	for (i = 0; i <= n - 1;i++)
	{
		scanf("%d %d %d %d", &info[i][0], &info[i][1], &info[i][2], &info[i][3]);
	}
	int room[12][10] = { 0 };
	int j, k, l, m;
	for (i = 0; i <= n - 1; i++)
	{
		if (info[i][0] == 1)
		{
			j = info[i][1];
			room[j-1][info[i][2]-1] += info[i][3];
		}
		else if (info[i][0]==2)
		{
			j = info[i][1];
			room[j+2][info[i][2]-1] += info[i][3];
		}
		else if (info[i][0]==3)
		{
			j = info[i][1];
			room[j+5][info[i][2]-1] += info[i][3];
		}
		else
		{
			j = info[i][1];
			room[j+8][info[i][2]-1] += info[i][3];
		}
	}
	for (k = 0; k <= 2; k++)
	{
		for (l = 0; l <= 8; l++)
		{
			printf(" %d", room[k][l]);
		}
		printf(" %d\n", room[k][9]);
	}
	printf("####################\n");
	for (k = 3; k <= 5; k++)
	{
		for (l = 0; l <= 8; l++)
		{
			printf(" %d", room[k][l]);
		}
		printf(" %d\n", room[k][9]);
	}
	printf("####################\n");
	for (k = 6; k <= 8; k++)
	{
		for (l = 0; l <= 8; l++)
		{
			printf(" %d", room[k][l]);
		}
		printf(" %d\n", room[k][9]);
	}
	printf("####################\n");
	for (k = 9; k <= 11; k++)
	{
		for (l = 0; l <= 8; l++)
		{
			printf(" %d", room[k][l]);
		}
		printf(" %d\n", room[k][9]);
	}
	return 0;

}

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

int main() {
  string s;
  cin >> s;
  int n = s.size() - 1;
  
  ll ans = 0;
  rep(bit, (1<<n)) {
	ll sum = 0;
    ll a = s[0] - '0';
	rep(i, n) {
      if (bit & (1<<i)) {
	    sum += a;
		a = 0;
	  }
	  a = a * 10 + (s[i + 1] - '0');
	}
    sum += a;
    ans += sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  10:00-
//A 10:05 AC
//B 10:15 AC
//C 10:21 AC


/*
3
2
1
*/
int solve(void){
	llint n,st,j,i,h,x;
	llint bas[61]={};
	bool fold[61]={};
	cin>>n;
	cin>>bas[n]>>x;
	if(n==0){return 0;}
	for(h=n;h>0;h--){
		if(bas[h]<=(1LL<<(h-1))){fold[h]=1;bas[h-1]=(1LL<<(h-1))+1-bas[h];}
		else{fold[h]=0;bas[h-1]=bas[h]-(1LL<<(h-1));}
		//cerr<<"bas["<<h-1<<"]="<<bas[h-1]<<endl;
	}
	for(h=1;h<=n;h++){
		if(x<=(1LL<<(n-h))){
			if(fold[h]){x=(1LL<<(n-h))+1-x;cout<<'L';}
			else{cout<<'R';}
		}else{
			if(fold[h]){x=(1LL<<(n-h+1))+1-x;cout<<'R';}
			else{x-=(1LL<<(n-h));cout<<'L';}
		}
	}
	cout<<endl;
	return 1;
}
int main(void){
	while(solve()){}
}



Measured memory_bytes: 3136
def f():
  lst=[]
  lst2=[]
  for _ in range(3):
      lst.append(input().split(" "))
  n=int(input())
  for i in range(n):
    lst2.append(input())
  for i in range(n):
    for j in range(3):
      for k in range(3):
        if lst[j][k]==lst2[i]:
          lst[j][k]="0"
  if lst[0][0]=="0" and lst[1][1]=="0" and lst[2][2]=="0":
    print("Yes")
    return()
  elif lst[0][2]=="0" and lst[1][1]=="0" and lst[2][0]=="0":
    print("Yes")
    return()
  else:
    for i in range(3):
      if lst[i][0]=="0" and lst[i][1]=="0" and lst[i][2]=="0":
        print("Yes")
        return()
      elif lst[0][i]=="0" and lst[1][i]=="0" and lst[2][i]=="0":
        print("Yes")
        return()
  print("No")
  return()

if __name__=="__main__":
  f()
  
  

Measured memory_bytes: 9188
N = gets.to_i
S = N.times.map{gets.chomp}
O = S.group_by(&:itself).to_a.sort_by{|s| s[1].size }.reverse
max = O.first[1].size
puts O.take_while{|v| v[1].size == max}.map{|v| v[0] }.sort

Measured memory_bytes: 64424
#include <iostream>
#include <cstdio>

using namespace std;

int main (void)
{
    string w;
    int alph_table[26];

    for (int i = 0; i < 26; i++) {
        alph_table[i] = 0;
    }

    cin >> w;
    for (int i = 0; i < w.size(); i++) {
        alph_table[w[i] - 'a']++;
    }

    bool beautiful = true;
    for (int i = 0; i < 26; i++) {
        if (alph_table[i] % 2 == 1) {
            beautiful = false;
            break;
        }
    }
    if (beautiful) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argA, argB;
	cin >> argA >> argB;

	ll ret0 = argA + argA - 1;
	ll ret1 = argA + argB;
	ll ret2 = argB + argB - 1;

	cout << max({ret0, ret1, ret2}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define snd second
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int A, V, B, W, T;

    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if (W > V) {
        cout << "NO" << endl;
        return 0;
    }

    if (W == V) {
        if (A == B) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    }

    int l = A > B ? A - B : B - A;
    bool ok = l <= T * (V-W);
    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    string s;
    cin >> s;
    s = "?" + s;
    for (int i = 1; i <= s.length(); ++i) {
        if((s[i] == 'K' || s[i] == 'B' || s[i] == 'R') && s[i-1] != 'A'){
            s = s.substr(0, i) + 'A' + s.substr(i, s.length()-i+1);
        }
    }
    if(s[s.length()-1] != 'A') s = s + 'A';
    if(s == "?AKIHABARA") cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


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

const int MAX_N=1e5+5;
bool ans[MAX_N];

int main(){
	int n;
	cin>>n;
	string str;
	cin>>str;
	for(int l=0;l<4;l++){
		fill(ans,ans+MAX_N,false);
		ans[0]=l%2;
		ans[1]=(l>>1)&1;
		bool last;
		if(str[0]=='o'){
			if(ans[0])last=ans[1];
			else last=ans[1]^1;
		}
		else {
			if(ans[0])last=ans[1]^1;
			else last=ans[1];
		}
		for(int i=1;i<n;i++){
			if(str[i]=='o'){
				if(ans[i])ans[i+1]=ans[i-1];
				else ans[i+1]=ans[i-1]^1;
			}
			else {
				if(ans[i])ans[i+1]=ans[i-1]^1;
				else ans[i+1]=ans[i-1];
			}
		}
		if(ans[0]==ans[n]&&last==ans[n-1])break;
		else if(l==3){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		if(ans[i])cout<<"S";
		else cout<<"W";
	}
	cout<<endl;
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> v( N + 1 );
	for( int i = 0; i < M; i++ ) {
		int a;
		cin >> a;
		v[a] = 1;
	}

	const long long MOD = 1000000000 + 7;
	vector<int> dp( N + 1 );
	dp[0] = 1;
	for( int i = 0; i <= N; i++ ) {
		if( i - 1 >= 0 && v[i - 1] == 0 ) {
			dp[i] += dp[i - 1];
			dp[i] %= MOD;
		}
		if( i - 2 >= 0 && v[i - 2] == 0 ) {
			dp[i] += dp[i - 2];
			dp[i] %= MOD;
		}
	}
	long long ans = dp[N];

	cout << ans << endl;
}


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

const int B = 60;

const int mod = 1e9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<int> cnt(B);
    for(int i = 0;i < N;i++){
        ll x;
        cin >> x;
        for(ll b = 0;b < B;b++){
            if(x & (1LL << b)) ++cnt[b];
        }
    }
    vector<ll> p2(B);
    p2[0] = 1;
    for(int i = 1;i < B;i++){
        p2[i] = p2[i - 1] * 2 % mod;
    }
    ll res = 0;
    for(ll i = 0;i < B;i++){
        res += (1LL * cnt[i] * (N - cnt[i])) % mod * p2[i] % mod;
    }
    cout << res % mod << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int ans=1;
    map<int,int> m;
    for(int i=1;i<=N;i++){
        int x=i;
        for(int j=2;j*j<=i;j++){
            while(x%j==0) {
                m[j]++;
                x/=j;
            }
        }
        m[x]++;
    }
    for(auto p:m){
        if(p.first==1) continue;
        ans*=((p.second+1)%MOD);
        ans%=MOD;
    }
    cout << ans << endl;



}


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

int main()
{
  double a, b, c, C, S, L, h, theta;
  cin >> a >> b >> C;
  theta = C * M_PI / 180.0;
  S = 0.5 * a * b * sin(theta);
  c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(theta));
  L = a + b + c;
  h = 2 * S / a;
  printf("%.8f\n%.8f\n%.8f\n", S, L, h);
}


Measured memory_bytes: 3508
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, A, B = MAP()

if A * B < N:
    print(-1)
    exit()
if A + B > N+1:
    print(-1)
    exit()
if A == 1 and B != N or B == 1 and A != N:
    print(-1)
    exit()
remain = N - A
if remain < B - 1:
    print(-1)
    exit()
d, m = divmod(remain, B-1) if B > 1 else (0, 0)
if d > A:
    print(-1)
    exit()
li = [[] for i in range(B)]
li[0] = list(range(1, A+1))
j = A + 1
for i in range(1, B):
    tmp = []
    for _ in range(d):
        tmp.append(j)
        j += 1
    if m > 0:
        tmp.append(j)
        j += 1
        m -= 1
    li[i] = tmp
li = li[::-1]
ans = []
for grp in li:
    ans += grp
print(*ans)


Measured memory_bytes: 42668
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	string S;
  	cin>>S;
  	int count[26]={0};
  	bool flag=false;
  	rep(i,S.size()) count[S[i]-97]++;
  
  	rep(i,26){
     	if(count[i]==0){
        	cout<<char('a'+i)<<endl;
          	flag=true;
          	break;
        }
      	
    }
  
  	if(!flag) cout<<"None"<<endl;
  
}

Measured memory_bytes: 3732
s = input()
ans = 0
t = [0 for i in range(len(s) + 1)]
tmp = 0
for i in range(1, len(s) + 1):
    if s[i - 1] == '<':
        tmp += 1
    else:
        tmp = 0
    t[i] = tmp

ans += t[len(s)]
tmp = 0
for i in range(len(s) - 1, -1, -1):
    if s[i] == '>':
        tmp += 1
    else:
        tmp = 0
    ans += max(tmp, t[i])
    
print(ans)
    

Measured memory_bytes: 24092
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
using namespace std;

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


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

int main() {
    int n;
    long long result = 0;
    cin >> n;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            for (int k=1; k<=n; k++) {
                result+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 3636
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    for (i, line) in stdin.lock().lines().enumerate() {
        let x:u16 = line.unwrap().trim().parse().unwrap();
        match x {
            0 => return,
            _ => println!("Case {}: {}", i+1, x),
        }
    }
}


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

maxR = [0] * n
maxL = [0] * n
maximum = 0
for i in range(n):
    maximum = max(maximum,a[i])
    maxL[i] = maximum
maximum = 0
for i in range(n):
    maximum = max(maximum,a[n-i-1])
    maxR[n-i-1] = maximum



for i in range(n):
    if i == 0:
        print(maxR[1])
    elif i == n-1:
        print(maxL[n-2])
    else:
        print(max(maxL[i-1],maxR[i+1]))

Measured memory_bytes: 72664
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
int main()
{
    ll n; cin>>n; ll a[n]; for(ll i=0;i<n;i++) cin>>a[i];
    ll c=0;
    for(ll i=0;i<n-2;i++)
    {
        for(ll j=i+1;j<n-1;j++)
        {
            for(ll k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i]+a[j]>a[k] && a[k]+a[i]>a[j] && a[j]+a[k]>a[i]) c++;
            }
        }
    }
    cout<<c;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll n,m; cin >> n >> m;
        if(!n && !m) break;
        vl h(n),w(m);
        vl sh(n+1,0), sw(m+1,0);
        rep(i,n) cin >> h[i];
        rep(i,m) cin >> w[i];
        rep(i,n) sh[i+1] = sh[i] + h[i];
        rep(i,m) sw[i+1] = sw[i] + w[i];
        map<ll,ll> H,W;
        rep(i,n){
            REP(j,i,n){
                H[sh[j+1] - sh[i]]++;
            }
        }
        rep(i,m){
            REP(j,i,m){
                W[sw[j+1] - sw[i]]++;
            }
        }
        ll ans = 0;
        for(auto i : H){
            if(W.find(i.first) != W.end()){
                ans += i.second * W[i.first];
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 38820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 10101010;
int main(){
    int n;
    cin >> n;
    ll mini = INF;
    ll maks = -1010101010;
    long long ans = 0;
    for (int i=0; i<n; i++){
        long long w;
        cin >> w;
        maks = max(maks, w);
        mini = min(mini, w);
        ans += w;
    }
    cout << mini << " " << maks << " " << ans << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long n,k,x,y;
    cin>>n>>k>>x>>y;
     if(n>k)
     {
         cout<<k*x+(n-k)*y<<endl;
     }
     else
     {
         cout<<n*x<<endl;
     }
     return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
/* Iterative Function to calculate (x^y) in O(log y) */
ll power(ll x, ll y) 
{ 
	int res = 1;	 // Initialize result 

	while (y > 0) 
	{ 
		// If y is odd, multiply x with result 
		if (y & 1) 
			res = res*x; 

		// y must be even now 
		y = y>>1; // y = y/2 
		x = x*x; // Change x to x^2 
	} 
	return res; 
}

int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
// vector<vector<ll>> v ;
// vector<ll> chld,bol,lst ;
// void dfs(ll a)
// {
//   lst.pb(a) ;
//   for(ll i=0;i<v[a].size();i++)
//   {
//     if(bol[v[a][i]]==0)
//     {
//       bol[v[a][i]]=1 ;
//       dfs(v[a][i]) ;
//     }
//   }
// }
// ll ch(ll a)
// {
//   ll p=0;
//   if(v[a].size()==0)
//   {
//     chld[a] =1 ;
//    return 1;
//   }
//   else
//   {
//     for(ll i=0;i<v[a].size();i++)
//     p += ch(v[a][i]) ;
//     p++ ;
//     chld[a] = p;
//     return p;
//   }
// }
int count(char x,string s)
{
  if(s.size()==1&&s[0]==x) return 0;
  else if(s.size()==1) return 1;
  else
  {
    ll a=0,b=0 ;
    for(ll i=0;i<s.size()/2;i++) if(s[i]==x) a++ ;
    for(ll i=s.size()/2;i<s.size();i++) if(s[i]==x) b++ ;
    return min(s.size()/2 - a + count(x+1,s.substr(s.size()/2,s.size()/2)),s.size()/2 - b + count(x+1,s.substr(0,s.size()/2))) ;
    
  }
}
int main()
{
  int n;
  cin >> n ;
  int a = n/1000 ;
  if(n%1000!=0)cout << (a+1)*1000 - n << endl ;
  else cout << "0" << endl;
}

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

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    if ( b < a ) { std::swap( a, b ); }
    if ( c < b ) { std::swap( b, c ); }
    if ( b < a ) { std::swap( a, b ); }

    std::cout
        << a << " " << b << " " << c
        << std::endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end()); // L をソートしておく (二分探索に必要)

    long long res = 0;
    
    // a と b を固定
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            // c の動ける範囲の右端を求める
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();

            // c の動ける範囲は、[j+1, k)
            res += max(k - (j+1), 0);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++){
        cout<<s[i]<<t[i];

    }
    
}

Measured memory_bytes: 256
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

dp=[0]*(w+1)

for i in range(n):
 for j in range(w,-1,-1):
  if j+l[i][0]<=w:
   dp[j+l[i][0]]=max(dp[j+l[i][0]],dp[j]+l[i][1])

print(max(dp))

Measured memory_bytes: 42604
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; 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;
    }
}

// 二項係数計算
ll 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;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N;
    cin >> N;
    vector<vector<bool>> yes(N,vector<bool>(10));
    vector<vector<ll>> mon(N,vector<ll>(11));
    ll n;
    rep(i,N){
        rep(j,10){
            cin >> n;
            if(n)yes[i][j] = true;
        }
    }
    rep(i,N){
        rep(j,11)cin >> mon[i][j];
    }
    ll ans = -1 * INF;
    for(ll i = 1;i < (1 << 10);i++){
        ll cnt = 0;
        //cout << i << "\n";
        rep(j,N){
            ll ka = 0;
            rep(k,10){
                if(i >> k&1){
                    if(yes[j][k])ka++;
                }
            }
            cnt += mon[j][ka];
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    /*rep(i,N){
        rep(j,10)cout << mon[i][j] << " ";
        cout << "\n";
    }*/
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

int p[510][510];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M, Q; cin >> N >> M >> Q;
    rep(_, M) {
        int L, R; cin >> L >> R;
        p[L][R]++;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            p[i][j] += p[i][j-1];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            p[i][j] += p[i-1][j];
        }
    }
    for (int i = 1; i <= Q; i++) {
        int L, R; cin >> L >> R;
        cout << p[R][R] + p[L-1][L-1] - p[L-1][R] - p[R][L-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, a: [i64; n],
    }
    let mut ok = true;
    for a in a {
        if a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0) {
            ok = false;
        }
    }
    puts!("{}\n", if ok { "APPROVED" } else { "DENIED" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            

            if (X == 3 || X == 5 || X == 7)
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13268