akhauriyash/Code-Regression huggingface dataset:
#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>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc079/tasks/abc079_c

int main() {
    string A; cin >> A;

    for (int msk = 0; msk < 8; msk++) {
        int num = A[0] - '0';
        string op = "";
        for (int j = 0; j < 3; j++) {
            if (msk & 1 << j) {
                num += A[j+1] - '0';
                op += "+";
            } else {
                num -= A[j+1] - '0';
                op += "-";
            }
        }
        if (num == 7) {
            printf("%c%c%c%c%c%c%c=7\n", A[0], op[0], A[1], op[1], A[2], op[2], A[3]);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,N) for(int i=0;i<(N);++(i))
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;
int R, C, sy, sx, gy, gx;
vector<string>maze(24);

int func(int sy,int sx){
	vector<vector<int>>dist(R, vector<int>(C, -1));
	queue<pair<int, int>>que;
	dist[sy][sx] = 0;
	que.push(make_pair(sy, sx));

	int y[4] = { 1,0,-1,0 };
	int x[4] = { 0,1,0,-1 };
	int ny, nx;
	while (!que.empty()) {
		pair<int, int>N = que.front();
		que.pop();
		rep(i, 4) {
			ny = N.first + y[i], nx = N.second + x[i];
			if (ny < 0 || nx < 0 || ny >= R || nx >= C || maze[ny][nx] == '#' || dist[ny][nx] != -1)continue;
			else {
				dist[ny][nx] = dist[N.first][N.second] + 1;
				que.push(make_pair(ny, nx));
			}
		}
	}
    int cnt=-1;
    rep(i,R){
        rep(j,C){
            cnt=max(cnt,dist[i][j]);
        }
    }
    return cnt;
}
int main() {
	cin >> R >> C;
	rep(i, R){
        cin >> maze[i];
    }
    int ans=-1;
    rep(i,R){
        rep(j,C){
            if(maze[i][j]=='.') ans=max(ans,func(i,j));
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                   /*--------------->Logic%2==0---------------->*/
#define CASE(t)                 printf("Case %d: ",t)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define PI                      2*acos(0.0)
#define ll                      long long int
#define endl                    '\n'
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n;
cin>>n;
vector<int>v;
int x;
for(int i=0;i<n;i++)
{
    cin>>x;
    v.push_back(x);
}
map<int,int>mp;
for(int i=0;i<n;i++)
{
    mp[v[i]]++;
}
int c=0;
for(auto u : mp)
{
    if(u.first>u.second)
    {
        c+=u.second;
    }
    else if(u.first<u.second)
    {
        c+=(u.second-u.first);
    }
}
cout<<c<<endl;
/*---------->HaPpY CoDiNg----------->*/
return 0;
}


Measured memory_bytes: 8116
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,m,x;
    cin>>n>>m>>x;
    long long int a=0,b=0;
    for(long long int i=0;i<m;i++)
    {
        long long int num;
        cin>>num;
        if(num>x)a++;
        else b++;
    }
    cout<<min(a,b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int sum[100010];
bool ok[100010];
bool isp[100010];

void func()
{
	isp[0] = isp[1] = true;
	for(int i = 2;i < 10000;i++)
	{
		if(!isp[i])
		{
			for(int j = 2*i;j < 100010;j += i)isp[j] = true;
		}
	}
	
	for(int i = 1;i < 100010;i++)
	{
		if(!isp[i] && !isp[(i+1)/2])ok[i] = true;
	}
	
	for(int i = 1;i < 100010;i++)
	{
		sum[i] = sum[i-1];
		if(ok[i])sum[i]++;
	}
	
}

int main()
{
	func();
	
	int q;cin >> q;
	
	REP(i,q)
	{
		int a,b;cin >> a >> b;
		cout << sum[b] - sum[a-1] << '\n';
	}
	
	return 0;
}


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

int main() {
    char A, B,C,D;
    scanf("%c%c%c%c",&A, &B, &C, &D);
    int E=A-'0', F=B-'0', G=C-'0', H=D-'0';
    int s=E,t,u,v;
    char a,b,c;
    for (int i=0;i<2;i++){
        if (i%2==0) {
            t=s+F;
            a='+';
        }
        else{
            t=s-F;
            a='-';
        }
        if(v==7) break;
        for (int j=0;j<2;j++){
            if (j%2==0){
                u=t+G;
                b='+';
            }
            else {
                u=t-G;
                b='-';
            }
            if (v==7) break;
            for (int k=0;k<2;k++){
                if (k%2==0) {
                    v=u+H;
                    c='+';
                }
                else {
                    v=u-H;
                    c='-';
                }
                if (v==7) {
                    printf("%d%c%d%c%d%c%d=7\n", E, a, F, b, G, c,H);
                    break;
                }
            }
        }
    }
}





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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    string S;

    cin >> S;
    if(S == "AAA" || S == "BBB") cout << "No" << "\n";
    else cout << "Yes" << endl;

return 0;
}

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

int main()
{
    string S;
    unsigned long int N, H, W, A[2000] = {0}, B[2000] = {0}, a, b, c, temp = 0, count = 0;
    double temp2;

    // N = 5;
    // A[0] = 3, A[1] = 11, A[2] = 14, A[3] = 5, A[4] = 13;
    cin >> N >> H >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        cin >> B[i];
    }

    for (int i = 0; i < N; i++)
    {
        if(A[i] >= H && B[i] >= W){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main() {
    ll A;
    string B;
    cin >> A >> B;
    string new_B = "";
    new_B += B[0];
    new_B += B[2];
    new_B += B[3];
    ll b = stoi(new_B);
    ll ans = A*b;
    cout << ans / 100 << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main()
{
	int n,a,i,x=0;
	char s[10000];
	scanf("%d %s",&n,s);
	a=strlen(s);
	for(i=0;i<a;i++){
		x=s[i]-'A';
		x=(x+n)%26;
		printf("%c",x+'A');
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1644
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,n;
signed main()
{
	cin>>a>>b>>n;
	if(b-1<=n)
	{
		cout<<a*(b-1)/b;
	}
	else cout<<a*n/b;
}

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


class dice{
    public:
    int face[7];
    string name;
    
    dice(){
    }
    
    void north(){
        face[6] = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = face[6];
       
    }
    
    void south(){
        face[6] = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = face[6];
    }
    
    void east(){
        face[6] = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = face[6];
    }
    
     void west(){
        face[6] = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = face[6];
    }
    

};
int get(dice d, int c1, int c2){
    for(int j = 0; j < 4; j++){
        for(int k = 0; k<4; k++){
            if(d.face[1] == c2){
                break;
            }
            d.south();
        }
        d.east();
    }    
    for(int k = 0; k<4; k++){
        if(d.face[0] == c1){
            return d.face[2];
        }
        d.east();
    }
    return -1;        
            
}

int main(){
    dice d1;
    int n;
    for(int i = 0; i < 6; i++){
        cin >> d1.face[i];
        //cout << d1.face[i] << endl;
    }
    cin >> n;
    int c1, c2;
    
    for(int i = 0; i < n; i++){
        cin >> c1 >> c2;
        cout << get(d1, c1, c2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
/*
 * 2624.cc: Graph Automata Player
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

typedef bool BoolVec[MAX_N];

enum { ST_OK, ST_NA, ST_MANY };

struct BoolMatrix {
  int n;
  bool m[MAX_N][MAX_N];
  
  BoolMatrix(): n(0) {}
  BoolMatrix(int _n): n(_n) {};

  void init() { memset(m, 0, sizeof(m)); }
  void unit() {
    init();
    for (int i = 0; i < n; i++) m[i][i] = 1;
  }
  
  BoolMatrix operator+(const BoolMatrix& m0) {
    BoolMatrix mm(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) mm.m[i][j] = m[i][j] ^ m0.m[i][j];
    return mm;
  }

  BoolMatrix operator*(const BoolMatrix& m0) {
    BoolMatrix mm(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        mm.m[i][j] = 0;
        for (int k = 0; k < n; k++) mm.m[i][j] ^= m[i][k] & m0.m[k][j];
    }
    return mm;
  }

  BoolMatrix pow(int e) {
    BoolMatrix mm(n), m0 = *this;
    mm.unit();

    while (e > 0) {
      if (e & 1) mm = mm * m0;
      m0 = m0 * m0;
      e >>= 1;
    }
    return mm;
  }

  void solve(BoolVec &v, int &st) {
    st = ST_OK;

    for (int i = 0; i < n; i++) {
      if (! m[i][i])
	for (int j = i + 1; j < n; j++)
	  if (m[j][i]) {
	    for (int k = i; k < n; k++)
	      swap(m[i][k], m[j][k]);
	    swap(v[i], v[j]);
	    break;
	  }

      if (m[i][i])
	for (int j = i + 1; j < n; j++)
	  if (m[j][i]) {
	    for (int k = i; k < n; k++) m[j][k] ^= m[i][k];
	    v[j] ^= v[i];
	  }
    }
  
    for (int i = n - 1; i >= 0; i--) {
      if (m[i][i]) {
	for (int j = i - 1; j >= 0; j--)
	  if (m[j][i]) m[j][i] = false, v[j] ^= v[i];
      }
      else {
	bool ex = false;
	for (int j = i + 1; ! ex && j < n; j++) ex |= m[i][j];
	if (! ex && v[i]) {
	  st = ST_NA;
	  return;
	}
	st = ST_MANY;
      }
    }
  }

  void print() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) printf("%d ", m[i][j]);
      putchar('\n');
    }
  }
};

/* global variables */

/* subroutines */

BoolVec v;

/* main */

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

  BoolMatrix a(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a.m[i][j];

  for (int i = 0; i < n; i++) cin >> v[i];

  int t;
  cin >> t;

  BoolMatrix at = a.pow(t);

  int st;
  at.solve(v, st);
  //at.print(); printf("st=%d\n", st);

  if (st == ST_OK) {
    for (int i = 0; i < n; i++) {
      if (i) putchar(' ');
      printf("%d", v[i]);
    }
    putchar('\n');
  }
  else
    cout << (st == ST_NA ? "none" : "ambiguous") << endl;
  return 0;
}

Measured memory_bytes: 1528
N,W = map(int,input().split())
# dp=[[0 for i in range(N)] for j in range(W)]
dp =[[0 for j in range(W+1)]for i in range(N+1)]
v = []
w = []
for i in range(N):
    temp_v,temp_w = map(int,input().split())
    v.append(temp_v)
    w.append(temp_w)
    # if temp_w<=W:#一回配ってみる
    #     dp[temp_w] = temp_v
# print(dp[4][1])
ans = 0
for i in range(1,N+1):
    for j in range(1,W+1):
        if (j-w[i-1])<0:
            dp[i][j] = dp[i-1][j] 
        else:
            # print("i,j={},{}".format(i,j))
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1])
            # print("dp[i-1][j] = {}".format(dp[i-1][j]))
            # print("dp[i-1][j-w[i-1]] = {}".format(dp[i-1][j-w[i-1]]+v[i-1]))
            ans = max(ans,dp[i][j])
print(ans)


Measured memory_bytes: 25944
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextLong();
		long arr[] = new long[100000+5];
		for(int i=0; i<n; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			arr[a] += b;
		}
		long sum = 0;
		int ans = 0;
		for(int i=0; i<arr.length; i++) {
			sum += arr[i];
			if(sum>=k) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 59668
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        int K = nint();
        char[] S = nsToChars();
        
        int[] c = new int[N+2];
        int i_c = 0;
        char cur = '0';
        for (int n = 0; n < N; n++) {
            if (cur != S[n]) {
                i_c++;
                cur = S[n];
            }
            c[i_c]++;
        }
        if (cur == '1') {
            i_c++;
        }
        
        int[] c2 = new int[i_c+3];
        System.arraycopy(c, 0, c2, 1, i_c+1);
        
        int[] sum = new int[c2.length];
        for (int i = 1; i < sum.length; i++) {
            sum[i] = sum[i-1] + c2[i];
        }
        
        int range = 2*K;
        if (range >= sum.length) {
            System.out.println(N);
            return;
        }
        
        int ans = sum[range];
        for (int i = 2; i + range < sum.length; i += 2) {
            ans = Math.max(ans, sum[i+range] - sum[i-1]);
        }
        System.out.println(ans);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,a;
    cin>>n>>x;a=x;
    ll l1[n+5];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        if(i==1)x=__gcd(abs(a-l1[i]),abs(a-l1[i]));
        else x=__gcd(x,abs(a-l1[i]));
    }
    cout<<x<<endl;
}


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

ll N;
int cnt = 0;
vector<int>sft = {3,5,7};

ll vectoint(vector<int>vec){
    int n = vec.size();
    ll ans  =0;
    for (int i=0; i<n; i++){
        ans += vec[n-1-i] * pow(10,i);
    }
    return ans;
}


//参考: https://drken1215.hatenablog.com/entry/2020/05/04/190252
void dfs(vector<int> &A) {
    // 数列の長さが N に達したら打ち切り
    if (vectoint(A) >  N) {
        // 処理
        return;
    }
    else {
        map<int,bool>mp;
        for (int i=0; i<A.size(); i++){
            mp[A[i]] = true;
        }
        if (mp[7] and mp[5] and mp[3]){
            //cout << vectoint(A) << endl;
            cnt++;
        }
    }

    for (int v = 0; v < 3; ++v) {
        A.push_back(sft[v]);
        dfs(A);
        A.pop_back();
    }
}


int main() {
    cin >> N;
    vector<int> A;
    dfs(A);
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

int n, ans, c = 1, a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) c++;
		else ans += c < a[i] ? c : c - a[i], c = 1;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
#define int ll

int n,h;
int a[100010],b[100010];
int maxa=0;

signed main(){
    cin>>n>>h;
    rep(i,0,n){
        cin>>a[i]>>b[i];
        if(maxa<a[i])maxa=a[i];
    }
    sort(b,b+n,greater<int>());
    int cnt=0;
    rep(i,0,n){
        if(maxa<b[i])h-=b[i],cnt++;
        if(h<=0)break;
    }
    
    if(h>0)cnt+=h/maxa+(h%maxa?1:0);
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int W = scan.nextInt();
		int[]v = new int[N + 1];
		int[]w = new int[N + 1];
		for(int i = 1; i <= N; i++) {
			v[i] = scan.nextInt();
			w[i] = scan.nextInt();
		}
		scan.close();
		int[]dp = new int[W + 1];
		dp[0] = 0;
		int max = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j <= W; j++) {
				if(j + w[i] <= W) {
					dp[j + w[i]] = Math.max(dp[j + w[i]], dp[j] + v[i]);
					max = Math.max(max, dp[j + w[i]]);
				}
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 26836
while true do
  n = gets.to_i
  break if n == 0

  hash = {}
  syachiku = {}
  n.times do |i|
    no, kakaku, kosu = gets.chop.split.map(&:to_i)
    hash[no] = hash.key?(no) ? hash[no] + kakaku * kosu : kakaku * kosu
    if hash[no] >= 1000000 then
      syachiku[no] = true
    end
  end
  if syachiku.keys.count == 0 then
    puts "NA"
  else
    syachiku.keys.each do |k|
      puts k
    end
  end
end


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

using namespace std;

#define rep(i, n) for(int i = 0; i < static_cast<int>(n); ++i)
#define per(i, n) for(int i = static_cast<int>(n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}

ll dp[110][5][2];

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

    string n;
    int k;
    cin >> n >> k;
    int l = (int)n.size();
    
    dp[0][0][0] = 1;
    for(int i = 0; i < l; ++i){
        for(int j = 0; j <= 3; ++j){
            for(int sm = 0; sm <= 1; ++sm){
                int mx = sm ? 9 : (n[i]-'0');
                for(int x = 0; x <= mx; ++x){
                    dp[i+1][j+(x!=0)][sm||(x<mx)] += dp[i][j][sm];
                }
            }
        }
    }
    cout << dp[l][k][0] + dp[l][k][1] << '\n';

    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int h, w;
pair<int, int> p;
queue<pair<int, int>> q;
int f(vector<vector<int>>& t)
{
    p = q.front();
    int i = p.first, j = p.second;
    int n = t[i][j]+1, f = 0;
    if(i-1 >= 0 && t[i-1][j] == -1) {
        t[i-1][j] = n;
        p.first = i-1; p.second = j;
        q.push(p);
        f = 1;
    }
    if(i+1 <  h && t[i+1][j] == -1) {
        t[i+1][j] = n;
        p.first = i+1; p.second = j;
        q.push(p);
        f = 1;
    }
    if(j-1 >= 0 && t[i][j-1] == -1) {
        t[i][j-1] = n;
        p.first = i; p.second = j-1;
        q.push(p);
        f = 1;
    }
    if(j+1 <  w && t[i][j+1] == -1) {
        t[i][j+1] = n;
        p.first = i; p.second = j+1;
        q.push(p);
        f = 1;
    }
    q.pop();
    return (f ? n : n-1);
}
int main()
{
    string u;
    char c;
    int ans = 0;
    cin >> h >> w;
    vector<vector<int>> s(h, vector<int> (w, 0)), t;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> c;
            if(c == '.') s[i][j] = -1;
            else         s[i][j] = -2;
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == -1) {
                t = s;
                t[i][j] = 0;
                p.first = i, p.second = j;
                q.push(p);
                while(q.empty() == 0) {
                    ans = max(ans, f(t));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  bool ok[N];
  int tmp1, tmp2;
  for(int i=0;i<N;++i) {
    cin>>tmp1>>tmp2;
    if(tmp1==tmp2) ok[i] = true;
    else ok[i] = false;
  }
  bool can = false;
  for(int i=0;i<N-2;++i) {
    if(ok[i] && ok[i+1] && ok[i+2]) can = true;
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;
 
    return res;
}
int findlcm(int arr[], int n)
{
    // Initialize result
    int ans = arr[0];
 
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
 
    return ans;
}
bool prime[100001];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
 
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
 
//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007
 
// Declare all the variables and global functions here -
int n;
int32_t main(){
    IOS;
    int x,a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
        return 0;
    }
    else{
        cout << 10 << endl;
    }
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k,j;
    long long int result,minn,t;
    cin>>n;
    int ar[101];
    for(i=0;i<n;i++)
        cin>>ar[i];
     minn=INT_MAX;
    for(k=1;k<=100;k++)
    {
        result=0;
        for(i=0;i<n;i++)
        {
            t=(ar[i]-k)*(ar[i]-k);
            result=result+t;
        }
        if(result<minn)
        {
            minn=result;
        }
    }
    cout<<minn;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

bool s[110][110];

int main(){
	int H, W, n;
	cin >> W >> H >> n;
	rep(i, n) {
		int X, Y, a;
		cin >> X >> Y >> a;
		if(a == 1) {
			for(int x = 0; x < X; x++) {
				for(int y = 0; y <= H; y++) s[y][x] = true;
			}
		}
		else if(a == 2) {
			for(int x = X; x < W; x++) {
				for(int y = 0; y < H; y++) s[y][x] = true;
			}
		}
		else if(a == 3) {
			for(int y = 0; y < Y; y++) {
				for(int x = 0; x < W; x++) s[y][x] = true;
			}
		}
		else {
			for(int y  = Y; y < H; y++) {
				for(int x = 0; x < W; x++) s[y][x] = true;
			}
		}
	}	
	int ans = 0;
	for(int x = 0; x< W; x++) {
		for(int y = 0; y < H; y++) if(!s[y][x]) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
        long long n, k, sum=0;
        long long bnd=pow(10, 9)+7;
        cin>>n>>k;
        for(long long i=k;i<=(n+1);i++){
                long long temp=((n-i+1)*i)+1;
                sum+=temp;
                sum%=bnd;
        }cout<<sum<<endl;
        return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define eef(i,x)for(int i=head[x],y=e[i].to;y;i=e[i].next,y=e[i].to)
int read(){char c=getchar();int d=0,f=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());return d*f;}
char Read(){char c=getchar();while(c<'0'||c>'9')c=getchar();return c;}
int getdigit(char c){return (c<'0'||c>'9')?-1e9:(c-'0');}
typedef pair<int,int>PII;
typedef long long LL;
const double pi=acos(-1);
const int N=1510,mod=1e9+7;
int n,c1[N][N],c2[N][N];LL ans,dp[N][N];
char a[N][N];
int main(){
	n=read();
	ref(i,1,n)scanf("%s",a[i]+1);
	ref(i,1,n){
		if(i==1){
			ref(j,1,n)dp[i][j]=max(0LL,dp[i][j-1]+getdigit(a[i][j]));
			ref(j,1,n)c1[j][1]=j;
			continue;
		}
		ref(j,1,n){
			bool w1=getdigit(a[i][j-1])>=0,w2=getdigit(a[i-1][j])>=0;
			bool W1=getdigit(a[i-1][j-1])>=0,W2=getdigit(a[i-2][j])>=0;
			ref(k,1,i){
				int C1=0;
				if(k==i)C1=j;else{
					if(w1)C1=c1[j-1][k];
					if(w2)C1=max(C1,c1[j][k]);
				}
				c1[j][k]=C1;
			}
			ref(k,1,i-1){
				int C2=1e9;
				if(k==i-1)C2=j;
				if(W1)C2=c2[j-1][k];
				if(W2&&k!=i-1)C2=min(C2,c2[j][k]);
				c2[j][k]=C2;
			}
		}
		ref(j,1,n)if(getdigit(a[i][j])>=0){
			int v=getdigit(a[i][j]);
			bool w1=getdigit(a[i][j-1])>=0,w2=getdigit(a[i-1][j])>=0;
			if(j==1){
				dp[i][j]=dp[i-1][j];
			}else if(j>1){
				if(!w1&&!w2)dp[i][j]=0;else
				if( w1&&!w2)dp[i][j]=dp[i][j-1];else
				if(!w1&& w2)dp[i][j]=dp[i-1][j];else
				if( w1&& w2){
					LL s=dp[i-1][j]+dp[i][j-1],la=1e9;
					def(k,i-1,1){
						if(c1[j-1][k]>=c2[j][k]&&la>c1[j-1][k])
							s-=dp[k][c1[j-1][k]];
						la=c2[j][k];
					}
					dp[i][j]=s;
				}
			}
			dp[i][j]+=v;
		}
	}
	ref(i,1,n)ref(j,1,n){
		int v=getdigit(a[i][j]);
		if(v>=0)ans+=(dp[i][j]-v)*v;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 38144
H, W = map(int, input().split())
maze = []
distances = []
n_aisle = 0
for i in range(H):
    row = input()
    maze.append(row)
    distances.append([100000000 for i in range(W)])
    n_aisle += row.count('.')

distances[0][0] = 0
directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]

visited = [(0, 0)]
queue = [(0, 0)]
while len(queue) > 0:
    y, x = queue.pop(0)
    for dy, dx in directions:
        y2, x2 = y + dy, x + dx
        if y2 < 0 or y2 >= H or x2 < 0 or x2 >= W:
            continue
        if (y2, x2) in visited:
            continue
        if maze[y2][x2] == '.':
            distances[y2][x2] = distances[y][x] + 1
            visited.append((y2, x2))
            queue.append((y2, x2))

if distances[H - 1][W - 1] == 100000000:
    print(-1)
else:
    print(n_aisle - distances[H - 1][W - 1] - 1)

Measured memory_bytes: 3188
N,C,K,*ts=$<.read.split.map(&:to_i)
ts.sort!
ts.push(10**10)

count = 0
x = ts.shift
n = 1
ts.each do |t|
    if K < t-x
        count += 1
        x = t
        n = 1
    else
        n += 1
        if C < n
            count += 1
            x = t
            n = 1
        end
    end
end

puts count

Measured memory_bytes: 10472
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    int c[3][3] = {0};
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int a[3] = {0},b[3]={0} ;

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

    a[1] = c[1][1] - b[1];
    a[2] = c[2][2] - b[2];

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if (c[i][j] != a[j]+b[i])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;


    return 0;
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
typedef long long s64;
const int N=2e5+5,D=1e9+7;
char s[N];
s64 dp[N],sum[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	scanf("%s",s+1);
	if(s[1]=='B')
	rep(i,1,m)s[i]="RB"[s[i]=='R'];
	int mn[2]={N,N},now=0;
	rep(i,1,m)
	if(s[i]=='R')++now;
	else 
	{
		if(now)chmin(mn[now%2],now);
		now=0;
	}
	if(now==m)
	{
		dp[0]=1;
		rep(i,2,n+2)dp[i]=(dp[i-1]+dp[i-2])%D;
		cout<<(dp[n]+dp[n+2])%D<<endl;
	}
	else
	{
		int fir=1;
		while(s[fir]=='R')++fir;
		if(fir%2)chmin(mn[1],fir);
		if(n%2){puts("0");exit(0);}
		dp[0]=sum[0]=1;
		rep(i,2,n)
		{
			dp[i]=sum[i-2];
			int j=i-mn[1]-1-2;
			if(j>=0)dp[i]-=sum[j];
			dp[i]%=D;
			sum[i]=(sum[i-2]+dp[i])%D;
		}
		s64 ans=0;
		rep(x,0,min(n/2-1,mn[1]/2))
		{
			ans+=sum[n-2*x-2];
			if(mn[1]+3<=n)ans-=sum[n-mn[1]-1-2];
		}
		cout<<(ans*2%D+D)%D<<endl;
	}
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    LL N;
    cin >> N;

    LL T = 0, A = 0;

    cin >> T >> A;

    for(LL i = 1; i < N; i++){
        LL t, a;
        cin >> t >> a;

        LL x = T / t, y = A / a;

        Vl st;
        if(x * t >= T && x * a >= A)
            st.Pb(x);
        if(y * t >= T && y * a >= A)
            st.Pb(y);
        x++, y++;
        if(x * t >= T && x * a >= A)
            st.Pb(x);
        if(y * t >= T && y * a >= A)
            st.Pb(y);

        sort(All(st));
        T = t * st[0], A = a * st[0];
    }

    cout << T + A << '\n';
    return 0;
}


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

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<VVV> VVVV;
typedef tuple<int,int> P;
typedef vector<P> VP;
typedef vector<VP> VVP;
int isLC(char c){
    if('a'<=c&&c<='z')return c-'a';
    else return -1;
}
int isUC(char c){
    if('A'<=c&&c<='Z')return c-'A';
    else return -2;
}
bool inner(int lb,int c,int ub){
    return lb<=c&&c<=ub;
}
int f(int rbg,int red,int cbg,int ced,vector<string>& s,VVVV &memo,VVP&U){
    if(memo[rbg][cbg][red][ced]!=-2)return memo[rbg][cbg][red][ced];
    //cout<<cbg<<" "<<ced<<endl;
    int R=1+red-rbg;
    int C=1+ced-cbg;
    VV dp(R,V(C,-1));
    dp[0][0]=0;
    int x=isLC(s[rbg][cbg]);
    int y=isUC(s[red][ced]);
    if(x==y){
        s[rbg][cbg]='.';
        s[red][ced]='.';
        dp[0][0]++;
    }
    for(int r=rbg;r<=red;r++){
        for(int c=cbg;c<=ced;c++){
            int i=r-rbg;
            int j=c-cbg;
            if(dp[i][j]==-1)continue;
            int id=isLC(s[r][c]);
            if(id>=0){
                for(auto &it:U[id]){
                    int nr,nc;
                    tie(nr,nc)=it;
                    if(inner(r,nr,red)&&inner(c,nc,ced)&&isLC(s[r][c])==isUC(s[nr][nc])){
                        int val=f(r,nr,c,nc,s,memo,U);
                        int ni=nr-rbg;
                        int nj=nc-cbg;
                        if(val!=-1)
                            dp[ni][nj]=max(dp[ni][nj],dp[i][j]+val);
                    }
                }            
            }
            if(r!=red&&s[r+1][c]!='#')dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(c!=ced&&s[r][c+1]!='#')dp[i][j+1]=max(dp[i][j+1],dp[i][j]);
        }     
    }
    if(x==y){
        s[rbg][cbg]=x+'a';
        s[red][ced]=y+'A';
    }
    //cout<<rbg<<" "<<red<<" "<<dp[R-1][C-1]<<endl;
    return memo[rbg][cbg][red][ced]=dp[R-1][C-1];
}


int main(){
    for(int R,C;cin>>R>>C,R+C;){
        vector<string> s(R);
        for(auto &it:s)cin>>it;
        VVP uc(26);
        for(int i=0;i<R;i++)
            for(int j=0;j<C;j++){
                int id=isUC(s[i][j]);
                if(id>=0)uc[id].push_back(P(i,j));
            }
        VVVV memo(R,VVV(C,VV(R,V(C,-2))));
        cout<<f(0,R-1,0,C-1,s,memo,uc)<<endl;

    }

    return 0;
}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

vector<int> arr;
int dp[100007][2];

int f(int k, int player) {

	if(k < 0) {
		return (player);
	}

	if(dp[k][player] != -1)
		return dp[k][player];

	for(int x: arr) {
		if(f(k - x, player ^ 1) == player) {
			return dp[k][player] = player;
		}
	}
	return dp[k][player] = player^1;
}

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

  memset(dp, -1, sizeof dp);

  int n, k;

  cin >> n >> k;

  arr.resize(n);

  for(int &x: arr)
  	cin >> x;

  cout << (f(k, 0) ? "Second" : "First") << endl;

}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        int p;
        cin >> p;
        v[i] = make_pair(p, i);
    }
    sort(all(v));
    reverse(all(v));
    vector<int> p(n);
    rep(i, n) {
        p[i] = v[i].second;
    }
    // rep(i, n) cout << p[i] << " ";
    // cout << endl;
    set<int> st;
    st.insert(-2);
    st.insert(-1);
    st.insert(n);
    st.insert(n + 1);

    ll ans = 0;
    rep(i, n) {
        int num = n - i;
        auto itr = st.lower_bound(p[i]);
        itr++;
        int rightsright = *itr;
        itr--;
        int right = *itr;
        itr--;
        int left = *itr;
        itr--;
        int leftsleft = *itr;

        ll now = 0;
        if (left != -1) {
            now += (ll)(left - leftsleft) * (right - p[i]);
        }
        if (right != n) {
            now += (ll)(rightsright - right) * (p[i] - left);
        }
        now *= (ll)num;
        ans += now;
        st.insert(p[i]);
        // for (int x : st) cout << x << " ";
        // cout << endl;
        // cout << left << " " << right << endl;
        // cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B;
  int K;
  cin>>A>>B>>K;
  if(B-A+1<=2*K){
    for(int i=A;i<B+1;i++){
      cout<<i<<endl;
    }
  }
  else{
    for(int i=0;i<K;i++){
      cout<<A+i<<endl;
    }
    for(int i=0;i<K;i++){
      cout<<B+1-K+i<<endl;
    }
  }
}


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

int main() {

  int A,B,C;
  cin >> A >> B >> C;
  int ans = 0;
  if((A*C) <= B){
    ans = C;
  }
  else{
    ans = B/A;
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int m, n, sum;
int ans1, ans2;

int main(void) {

	for (;;) {
		scanf("%d%d", &m, &n);

		if ((0 <= n) && (n <= 100) && (0 <= m) && (m <= 100) && (0 <= m + n)) {
			break;
		}
	}

	ans1 = m * (m - 1) / 2;
	ans2 = n * (n - 1) / 2;

	sum = ans1 + ans2;

	printf("%d\n", sum);

	return 0;
}

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

int main() {
    int N; string S; cin >> N >> S;
    rep(i, S.size())
        cout << (char)('A' + (S[i] - 'A' + N) % 26);

    cout << endl;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(A < 9 && B < 9 ? "Yay!" : ":(");
        }
    }
}

Measured memory_bytes: 11348
using System;
using System.Linq;
using static System.Console;
 
public class A{
  static void Main(string[] args)
  {
    var s = Array.ConvertAll(new string[] { ReadLine(), ReadLine(), ReadLine(), ReadLine(), ReadLine() }, int.Parse);
    var k = int.Parse(ReadLine());
    WriteLine(s.Max() - s.Min() <= k ? "Yay!" : ":(");
  }
}

Measured memory_bytes: 13268
fun main(args:Array<String>){
    val line = readLine()!!.split(" ").map{it.toInt()}
    val n = line[0]
    val m = line[1]
    var max = n
    var min = 1
    for(i in 1..m){
        val line2 = readLine()!!.split(" ").map{it.toInt()}
        val l = line2[0]
        val r = line2[1]
        if(l>min){
            min = l
        }
        if(r<max){
            max = r
        }
    }
    if(min>max){
        println(0)
    }else{
        println(max-min+1)
    }
}

Measured memory_bytes: 51692
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size();i++){
        int tmp=0;
        for (int j = i; j < s.size();j++){
            if (s[j] == 'A' || s[j] == 'G' || s[j] == 'T' || s[j] == 'C')
            {
                tmp++;
            }else{
                break;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
ans = [0]*N
cnt = 0
for i in range(N):
    if S[i] == "L":
        if cnt % 2 ==0:
            ans[i] += cnt//2
            ans[i-1] += cnt//2
            cnt = 0
        else:
            ans[i] += (cnt-1)//2
            ans[i-1] += (cnt+1)//2
            cnt = 0
    else:
        cnt += 1
cnt = 0
for i in reversed(range(N)):
    if S[i] == "R":
        if cnt % 2 ==0:
            ans[i] += cnt//2
            ans[i+1] += cnt//2
            cnt = 0
        else:
            ans[i] += (cnt-1)//2
            ans[i+1] += (cnt+1)//2
            cnt = 0
    else:
        cnt += 1

ans = [str(a) for a in ans]
print(" ".join(ans))

Measured memory_bytes: 49264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n=5;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    if(a[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
}


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

using namespace std;

int x,y;
int asex[16005],asey[16005],cntx=0,cnty=0;

bitset <960005> hobex;
bitset <960005> hobey;

int main()
{
    char s[8005];
    scanf("%s %d%d",s,&x,&y);
    int sumx=0,sumy=0;
    int len=strlen(s),bam=0,h=0;
    s[len]='T';
    for(int i=0; i<=len; i++)
    {
        if(s[i]=='F')
        {
            h++;
        }
        else
        {
            if(bam==0)
            {
                sumx+=h;
                asex[cntx++]=2*h;
                bam=1;
                h=0;
            }
            else
            {
                sumy+=h;
                asey[cnty++]=2*h;
                bam=0;
                h=0;
            }
        }
    }
    hobex.set(0);
    hobey.set(0);
    hobex[sumx+16000]=1;
    hobey[sumy+16000]=1;
    for(int i=1;i<cntx;i++)
    {
            hobex|=(hobex>>asex[i]);
    }
    hobex[0]=0;
    for(int i=0;i<cnty;i++)
    {
            hobey|=(hobey>>asey[i]);
    }
    hobey[0]=0;
    if(hobex[x+16000]&&hobey[y+16000])
        printf("Yes\n");
    else
        printf("No\n");
}

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

int main()
{
	int price[5];

	for (int i = 0; i < 5; i++){
		cin >> price[i];
	}
	
	cout << min(price[0], min(price[1], price[2])) + min(price[3], price[4]) - 50 << endl;

	return (0);
}

Measured memory_bytes: 1160