akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    vector<char> a(3);
    int sum = 0;
    rep(i,1<<3){
        sum = s[0] - '0';
        rep(j,3){
            if(i & (1<<j)){
                sum -= s[j+1] - '0';
                a[j] = '-';
            }else{
                sum += s[j+1] - '0';
                a[j] = '+';
            }
        }
        if(sum == 7){
            cout << s[0] << a[0] << s[1] << a[1] << s[2] << a[2] << s[3] << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

ll euclidean_gcd(ll a, ll b){
	if(a < b) return euclidean_gcd(b,a);
	ll r;
	while(a % b != 0){
		r = a % b;
		a = b;
		b = r;
	}
	return b;
}

ll num_A_to_B(ll A, ll B, ll num){
	ll ans = B/num - A/num;
	if(A%num == 0) ans++;
	return ans;
}

int main()
{
	ll A,B,C,D;
	cin >> A >> B >> C >> D;
	ll lcm = (C*D)/euclidean_gcd(C,D);
	cout << B - A + 1 - ( num_A_to_B(A,B,C) + num_A_to_B(A,B,D) - num_A_to_B(A,B,lcm)) << endl;
	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if (b < a) swap(a, b);
  if ((b - a) & 1) cout << "IMPOSSIBLE" << endl;
  else{
    cout << a + (b - a) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int H, W, h, w;
  std::cin >> H >> W >> h >> w;
  cout(H*W - h * W - H * w + h * w); 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cstdint>
#include<algorithm>
using namespace std;

const int MAX = 100000;
const int64_t INF = 4611686018427387903; // 2^62-1、使わない辺とかに用いる

typedef struct node {
	int myID; // ユニークID, まぁデバッグ用？
	vector<pair<int, int> > edge; // 移動辺
	vector<int64_t> costs; // 確定したコスト
	bool done; // 確定ノードか否か
	int64_t cost; // 現時点のコスト
	
	bool operator<(const node& a) const {
		return cost > a.cost;
	}
} Node;

typedef class dijkstra {
	private:
		int N; // 頂点数
		vector<Node> node;
		void init(int s);
	public:
		dijkstra(int n);
		void addEdge(int n, int m, int cost);
		void calc(int s);
		int64_t getCost(int s, int t);
} Dijkstra;

/**
 * 頂点数を渡してください、初期化します。
 * @param n 頂点の数
 */
dijkstra::dijkstra(int n) {
	N = n;
	node.resize(n);
	for (int i = 0;i < N;i ++) {
		node[i].edge.clear();
		node[i].myID = i;
	}
}

/**
 * 頂点nと頂点mの間にcostの重み付き無向辺を作ります。
 * @param n 行く側の頂点
 * @param m 向かう側の頂点
 * @param cost 移動コスト
 */
void dijkstra::addEdge(int n, int m, int cost) {
	node[n].edge.push_back(make_pair(m, cost));
	node[m].edge.push_back(make_pair(n, cost));
}

void dijkstra::init(int s) {
	for (int i = 0;i < N;i ++) {
		node[i].done = false;
		node[i].cost = INF;
	}
	node[s].cost = 0;
}
/**
 * ダイクストラ法を実行します。O(VlogE)です。
 */
void dijkstra::calc(int s) {
	init(s);
	priority_queue<Node> que; // コスト、頂点
	que.push(node[s]);
	
	Node check;
	while(!que.empty()) {
		check = que.top();
		que.pop();
		
		check.done = true;
		for (int i = 0;i < check.edge.size();i ++) {
			if (check.cost + check.edge[i].second < node[check.edge[i].first].cost) { // より近い経路発見！
				node[check.edge[i].first].cost = check.cost + check.edge[i].second;
				que.push(node[check.edge[i].first]);
			}
		}
	}
	node[s].costs.resize(N);
	for (int i = 0;i < N;i ++) node[s].costs[i] = node[i].cost;
}

/**
 * 頂点sから頂点tへ行くまでの最短コストを返します。
 * @param s 始点となる頂点
 * @param t 終点となる頂点
 * @return sからtまでの最短コスト
 */
int64_t dijkstra::getCost(int s, int t) {
	return node[s].costs[t];
}

int main() {
	int n, m, s, t, u, v, a, b;
	cin >> n >> m >> s >> t;
	
	int64_t snuke = 1000000000000000; // 持ち金
	Dijkstra map1(n), map2(n);
	for (int i = 0;i < m;i ++) {
		cin >> u >> v >> a >> b;
		map1.addEdge(u - 1, v - 1, a);
		map2.addEdge(u - 1, v - 1, b);
	}
	map1.calc(s - 1);
	map2.calc(t - 1);
	
	static pair<int64_t, int> cost[MAX];
	for (int i = 0;i < n;i ++) { // iは両替を行う都市
		cost[i] = make_pair(map1.getCost(s - 1, i) + map2.getCost(t - 1, i), i);
	}
	
	sort(cost, cost+n);
	
	int read = 0;
	for (int i = 0;i < n;i ++) {
		while(cost[read].second < i) read ++; // その両替所は存在しない！
		
		cout << snuke - cost[read].first << endl;
	}
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

さて、下準備
まず、都市sから他の全ての都市への円を用いた最短経路を出す
次に、その全ての都市から都市tへのスヌークを用いた最短経路を出す 逆に出せば良いのよ、tからね

最後に、どの都市で両替したら良いかを最終スヌークが多い順にソートして持っておこう

さて、この時i年目について高速に求めてみよう
と言っても、答えはソートした奴を上から見て、両替所が存在していればそれが答え

DijkstraでO(nlog(m))、ソートにO(nlog(n))、上から見てくのO(n)だしO(nlog(m))かなぁ(O(max(n,m))=O(m)なので)
*/

Measured memory_bytes: 34032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);


int parent[100005];
int R[100005];

int find(int a){
    if(parent[a]==-1) return a;
    return parent[a] = find(parent[a]);
}

void merge(int a, int b){
    a = find(a);
    b = find(b);

    if(a==b) return;

    if(R[a] > R[b]){
        parent[b] = a;
        R[a] += R[b];
    }
    else{
        parent[a] = b;
        R[b] += R[a];
    }
}


void solve(){    

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

    vi friends[n+4];
    vi block[n+4];

    for(int i = 1;i<=n;i++){
        parent[i] = -1;
        R[i] = 1;
    }

    fo(i,m){
        int a,b;
        cin>>a>>b;
        merge(a,b);
        friends[a].pb(b);
        friends[b].pb(a);
    }
    fo(i,k){
        int a,b;
        cin>>a>>b;
        if(find(a)==find(b)){
            block[a].pb(b);
            block[b].pb(a);
        }
    }
    for(int i = 1;i<=n;i++){
        cout<<max(0LL,(int)R[find(i)]-(int)friends[i].size()-(int)block[i].size()-1)<<" ";
    }
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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

Measured memory_bytes: 16996
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
/*Main function*/
int main()
{
    int n;cin>>n;
    int lcm=(n*360)/__gcd(n,360);
    cout<<lcm/n;br;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

lint Q, H, S, D;
lint N, ans;

int main(void){
    // input
    cin >> Q >> H >> S >> D;
    cin >> N;
    while (N > 0) {
        if (N >= 2) {
            ans += (N / 2) * min({8*Q, 4*H, 2*S, D});
            N = N % 2;
        } else {
            N -= 1;
            ans += min({4*Q, 2*H, S});
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "iomanip"
#include "algorithm"
#include "vector"
#include "cmath"

int main() {
	char s[11], t[12];
	std::cin >> s;
	std::cin >> t;
	char* as = s, * at = t;
	bool ans = true;
	while (*as) {
		if (*as != *at)
			ans = false;
		as++;
		at++;
	}
	if (ans) {
		if (*at && *(at + 1) == '\0')
			ans = true;
		else ans = false;
	}

	if (ans)
		std::cout << "Yes";
	else
		std::cout << "No";
}

Measured memory_bytes: 3624
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    sort(All(d));
    // 1 2 3 4 5 6 7 8
    cout << d[(N/2+1)-1] - d[(N/2)-1] << nn;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 300005
int lowbit(int u){return u&(-u);}
int a[N],t[N],siz,n;
void add(int u)
{
	while(u<=siz)
	{
		t[u]++;
		u+=lowbit(u);
	}
}
int query(int u)
{
	int ans=0;
	while(u)
	{
		ans+=t[u];
		u-=lowbit(u);
	}
	return ans;
}
int getrev(vector<int> v)
{
	memset(t,0,sizeof(t));
	int ans=0;
	for(int i=(int)v.size()-1;i>=0;i--)
	{
		ans+=query(v[i]);
		add(v[i]);
	}
	return ans;
}
signed main()
{
	cin>>n;
	siz=n;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2!=i%2)
		{
			cout<<"No\n";
			return 0;
		}
	}
	vector<int> v;
	for(int i=1;i<=n;i+=2)
	{
		v.pb(a[i]);
	}
	int A=getrev(v);
	v.clear();
	for(int i=2;i<=n;i+=2)
	{
		v.pb(a[i]);
	}
	int B=getrev(v);
	v.clear();
	for(int i=1;i<=n;i++)
	{
		v.pb(a[i]);
	}
	int C=getrev(v);
	if((A+B)*3==C) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 12504
#include <stdio.h>

int main(){

	int x,y;
	
	while(1){
	scanf("%d %d",&x ,&y);
	if((x==0)&&(y==0)) break;
	else if(x>y) printf("%d %d\n",y,x);
	else if((x<y)||(x==y)) printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int ma = -1;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    ma = max(ma, tmp);
  }
  dump(sum-ma/2);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    _ = int(input())
    A = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7

    sum_A = sum(A) % mod
    ans = 0
    for a in A:
        sum_A += mod - a if sum_A < a else -a
        ans += a * sum_A
        ans %= mod
    print(ans % mod)


if __name__ == '__main__':
    main()


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

int main(){
    int n , m;
    cin>>n>>m;
    vector<int> a(10000000),b(10000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    long long int ans=0,ans2=0;
    for(int i=0;i<n;i++){
    ans=ans+a[i];
    }
    for(int i=0;i<m;i++){
    ans2=ans2+b[i];
    }
    
    cout <<ans*ans2<<endl;

    return 0;
}






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

int main(void)
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout << k << endl;
    }else if(a<k&&k<=(a+b)){
        cout<< a <<endl;
    }else{
        int ans = 2 * a + b - k;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

check_list = [False] * M
for i in range(M):
    flag = True
    for j in range(N):
        if i+1 not in l[j][1:]:
            flag = False
    if flag:
        check_list[i] = True

print(check_list.count(True))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	char data[101][101];
	bool f[101][101];
	int h,w;
	while(1){
		cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>data[j][i];
				f[j][i]=true;
			}
		}
		int x=0,y=0;
		while(1){
			if(!f[x][y]){
				cout<<"LOOP"<<endl;
				break;
			}
			f[x][y]=false;
			if(data[x][y]=='>')x++;
			else if(data[x][y]=='<')x--;
			else if(data[x][y]=='^')y--;
			else if(data[x][y]=='v')y++;
			else{
				cout<<x<<" "<<y<<endl;
				break;
			}
		}
	}
}

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

string s;
int A,B;

bool check(string s ) {
  if(s[A] != '-') return false;
  for ( int i = 0; i < A; i++ ) {
    if(s[i] < '0' || s[i] > '9' ) return false;
  }
  for ( int i = A+1; i < A+B+1; i++ ) {
    if(s[i] < '0' || s[i] > '9' ) return false;
  }
  return true;
}

int main() {

  cin >> A >> B >> s;
  if ( check(s) ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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


int main(){
    ll num;
    cin >> num;
    vector<pair<pair<string, ll> ,ll>> rest(num);
    vector<string> shop(num);
    for(ll i = 0; i < num; i++){
        string tmp_s;
        ll tmp_n;
        cin >> tmp_s >> tmp_n;
        rest[i] = make_pair(make_pair(tmp_s, tmp_n) , i + 1);
        shop[i] = tmp_s;
    }
    
    sort(rest.begin(), rest.end(),greater<pair<pair<string, ll> ,ll>>());
    
    sort(shop.begin() , shop.end());
    auto result = unique(shop.begin(),shop.end());
    shop.erase(result, shop.end());
    

    for(int j = 0; j < shop.size(); j++){
        for(int i = 0; i < num; i++){
            if(shop[j] == rest[i].first.first){
                cout << rest[i].second << endl;
            }
        }
    }


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,s=0,in[500][2],tate,yoko;
	for(i=0;i<500;i++){
		scanf("%d %d",&in[i][0],&in[i][1]);
		if(in[i][0]==0&&in[i][1]==0)
			break;
		s++;
	}
	for(i=0;i<s;i++){
		for(tate=0;tate<in[i][0];tate++){
			if(tate==0||tate==in[i][0]-1){
				for(yoko=0;yoko<in[i][1];yoko++){
					printf("#");
				}
				printf("\n");	
			}
			else{
				printf("#");
				for(yoko=1;yoko<in[i][1]-1;yoko++){
					printf(".");
				}
				printf("#\n");
			}
		}
		printf("\n");
	}
	
	return 0;
}


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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

int main() {

  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  int s = 0;
  while(a>0 && c>0){
    if(s == 0){
      c -= b;
      s = 1;
    }else{
      a -= d;
      s = 0;
    }
  }

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

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int h,w;
    cin >> h >> w;

    vector<vector<char>> pic(h+2,vector<char>(w+2,'#'));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> pic[i+1][j+1];
        }
    }

    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            cout << pic[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
    int k,n,x,y,sum;
    while(~scanf("%d%d%d%d",&n,&k,&x,&y))
    {
        sum=0;
        if(n>=k)
        {
            for(int i=1;i<=k;i++)
            {
                sum+=x;
            }
            for(int j=k;j<n;j++)
            {
                sum+=y;
            }
        }
        else
        {
            sum=x*n;
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

typedef struct List {
	struct List *next;
	int v, len;
} list;

int main()
{
	int i, u, w, D, N, M;
	scanf("%d %d", &N, &M);	
	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *d = (list*)malloc(sizeof(list) * M * 2);
	for (i = 0; i < M; i++) {
		scanf("%d %d %d", &u, &w, &D);
		d[i*2].v = w;
		d[i*2+1].v = u;
		d[i*2].len = D;
		d[i*2+1].len = -D;
		d[i*2].next = adj[u];
		d[i*2+1].next = adj[w];
		adj[u] = &(d[i*2]);
		adj[w] = &(d[i*2+1]);
	}
	
	int flag[100001] = {}, q[100001], head, tail;
	long long dist[100001];
	list* p;
	for (i = 1; i <= N; i++) {
		if (flag[i] == 1) continue;
		flag[i] = 1;
		dist[i] = 0;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (p = adj[u]; p != NULL; p = p->next) {
				w = p->v;
				if (flag[w] == 0) {
					flag[w] = 1;
					dist[w] = dist[u] + p->len;
					q[tail++] = w;
				} else if (dist[w] != dist[u] + p->len) break;
			}
			if (p != NULL) break;
		}
		if (head < tail) break;
	}
	if (i > N) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 8704
#include<stdio.h>
int main(void)
{  
  int h,w,i,j;
  do{
      scanf("%d %d",&h,&w);
      if((h==0)&&(w==0)){
        break;
      }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
          if((i%2==0)&&(j%2==0)){
            printf("#");
          }
          if((i%2==0)&&(j%2!=0)){
              printf(".");
          }
          if((i%2!=0)&&(j%2!=0)){
            printf("#");
          }
          if((i%2!=0)&&(j%2==0)){
              printf(".");
          }
      }
      printf("\n");
    }
    printf("\n");
  }while(1);
  return 0;
}
            
          
   
        


Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ABC11X_A();
		ABC11X_B();
		// ABC11X_C();
		// ABC11X_D();
	}

	private static void ABC11X_A() {
		Scanner scanner = null;
		int amountX = 0;
		int amountY = 0;

		try {
			scanner = new Scanner(System.in);
			amountX = scanner.nextInt();
			amountY = scanner.nextInt();

			int total = amountX + (amountY / 2);

			System.out.println(total);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_B() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			int numN = scanner.nextInt();
			double numT = scanner.nextInt();
			double numA = scanner.nextInt();

			double minA = Double.MAX_VALUE;
			int targetN = Integer.MAX_VALUE;
			double wkTemp = Double.MAX_VALUE;
			for (int i = 0; i < numN; i++) {
				wkTemp = Math.abs(numA - (numT - scanner.nextInt() * 0.006));
				if (minA > wkTemp) {
					minA = wkTemp;
					targetN = i;
				}
			}

			System.out.println(targetN + 1);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_C() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_D() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23764
t=[{(0,1),(1,0),(1,1)},
   {(1,0),(2,0),(3,0)},
   {(0,1),(0,2),(0,3)},
   {(1,-1),(1,0),(2,-1)},
   {(0,1),(1,1),(1,2)},
   {(1,0),(1,1),(2,1)},
   {(0,1),(1,-1),(1,0)}
]

while 1:
    l=[input() for _ in range(8)]
    pos=sorted([(i,j) for i in range(8) for j in range(8) if l[i][j]=="1"])
    cv=lambda v:tuple([v[0]-pos[0][0],v[1]-pos[0][1]])
    pt=set(map(cv,pos))
    [print(chr(65+i)) for (i,j) in enumerate(t) if pt&j==j]
    try:
        input()
    except:
        break



Measured memory_bytes: 5580
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll h, w; cin >> h >> w;
  string s;
  REP(_, h) {
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    int ad = abs(x - a);
    int bd = abs(x - b);
    char c = (ad < bd) ? 'A' : 'B';

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
A = abs(sum(W)-W[0])
ans = abs(sum(W) - W[0])
s1 = 0
s2 = 0
for T in range(N):
  for i in range(T+1):
    s1 += W[i]
  for j in range(T+1,N):
    s2 += W[j]
  S = abs(s1 - s2)
  B = min(A,S)
  ans = min(ans,B)
  s1 = 0
  s2 = 0
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main(){

  int N, n, k;
  int x[100000];
  int y[100000];

  cin >> N;
  while(N > 0){
    cin >> n >> k;

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

    if(n == 1){
      cout << 0 << endl;
      N--;
      continue;
    }

    REP(i, 1, n){
      y[i-1] = x[i] - x[i-1];
    }

    sort(y, y+n-1);
    reverse(y, y+n-1);

    int ans = 0;
    REP(i, k-1, n-1){
      ans += y[i];
    }
    cout << ans << endl;
    N--;
  }
}


Measured memory_bytes: 3824
import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val conn = Array(n) { mutableListOf<Int>()}

    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt()-1 }
        conn[a].add(b)
        conn[b].add(a)
    }

    val bfs = ArrayDeque<Int>()
    bfs.addLast(0)

    val ans = Array(n){0}
    ans[0] = -1

    while (bfs.isNotEmpty()) {
        val idx = bfs.removeFirst()

        conn[idx].forEach { nextIdx ->
            if (ans[nextIdx] != 0) return@forEach
            ans[nextIdx] = idx+1
            bfs.addLast(nextIdx)
        }
    }

    println("Yes")
    println(ans.takeLast(n-1).joinToString(separator = System.lineSeparator()))
}

Measured memory_bytes: 85412
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::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; }

int table[1005][1005];

int main() {
    int n; cin >> n;
    int x1, y1, x2, y2;
    rep(i, n) {
        cin >> x1 >> y1 >> x2 >> y2;
        table[y1][x1]++;
        table[y2][x2]++;
        table[y1][x2]--;
        table[y2][x1]--;
    }

    // 横方向累積和
    for (int i = 0; i < 1005; i++) {
        for (int j = 1; j < 1005; j++) {
            table[i][j] += table[i][j-1];
        }
    }
    // 縦方向
    for (int i = 1; i < 1005; i++) {
        for (int j = 0; j < 1005; j++) {
            table[i][j] += table[i-1][j];
        }
    }

    int ans = 0;
    rep(i, 1005) {
        rep(j, 1005) {
            ans = max(ans, table[i][j]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 7056
#include <iostream>

using namespace std;
int main()
{
    long long mas[500005];
    string a;
    long long ans=0;
    cin>>a;
    a=">"+a+"<";
    for(long long i=0; i<a.size()-1; i++){
        if(a[i]=='>' && a[i+1]=='<'){
            mas[i]=0;
        }else{
            mas[i]=-1;
        }
    }
    for(long long i=1; i<a.size()-1; i++){
        if(a[i]=='<'){
            if(mas[i-1]+1>mas[i]){
                if(mas[i]==-1){
                    ans--;
                }
                ans+=(mas[i-1]+1)-mas[i];
                mas[i]=mas[i-1]+1;
            }
        }
    }
    for(long long i=a.size()-2; i>=0; i--){
        if(a[i+1]=='>'){
            if(mas[i+1]+1>mas[i]){
                if(mas[i]==-1){
                    ans--;
                }
                ans+=(mas[i+1]+1)-mas[i];
                mas[i]=mas[i+1]+1;
            }
        }
    }
    cout<<ans;
}


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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + n - 1);
  for (int i = 0; i < n + n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  auto ok = [&](int mid) {
    int alt_left = 0, alt_right = 0;
    for (int j = n - 1; j - 1 >= 0 && (a[j] >= mid) != (a[j - 1] >= mid); j--) {
      alt_left++;
    }
    for (int j = n - 1; j + 1 < n + n - 1 && (a[j] >= mid) != (a[j + 1] >= mid); j++) {
      alt_right++;
    }
    return (a[n - 1] >= mid) ^ (min(alt_left, alt_right) & 1);
  };
  int low = 0, high = n + n - 1, mid;
  while (low < high) {
    mid = (low + high + 1) >> 1;
    if (ok(mid)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low + 1 << '\n';
  return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] ary = new int[3];
        for (int i = 0; i < 3; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);
        if (ary[0] + ary [1] == ary[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,a,b=MI()
    M=2*(10**5) + 5
    def cmb(n, r):
        if n - r < r: r = n - r
        if r == 0: return 1
        if r == 1: return n

        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]

        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot

        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
                result%=mod

        return result
        
    ans=pow(2,N,mod)-1
    ans-=cmb(N,a)
    ans-=cmb(N,b)
    
    print(ans%mod)

main()


Measured memory_bytes: 107444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7 ;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX =  1e5 + 10 ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , x , k , Q , ans ; string s,t;
int dp[3005][3005];
pair < int , int > nxt[3001][3001];
char take[3001][3001];
int solve(int i , int j){

   if(i == n || j == m)
        return 0;

   int &ret = dp[i][j];

   if(~ret)
    return ret;

    int a  = solve(i + 1,j);
    int b  = solve(i , j + 1);
    int c  = (s[i] == t[j]) + solve(i + 1,j + 1);

    ret = max({a,b,c});

    if(a == ret)
        nxt[i][j] = {i + 1 , j};


    if(b == ret)
        nxt[i][j] = {i,j + 1};

    if(c == ret){
        if(s[i] == t[j])
            take[i][j] = s[i];

        nxt[i][j] = {i + 1, j + 1};//,cout<<i<<' '<<j<<' '<<take[i][j]<<'\n';
    }


    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
//   freopen("test.in","r",stdin);
    ll w ;
    cin>>s>>t;
    n = (int)s.length();
    m = (int)t.length();

    for(int i = 0 ; i < n + 2; ++i)
        for(int j = 0 ; j < m + 2; ++j)
            dp[i][j] = -1,nxt[i][j]={-1,-1},take[i][j]='-';


   solve(0,0);

    int i = 0 , j = 0 ;
    string res = "";

    while(i!=-1){
        if(take[i][j]!='-')
            res+=take[i][j];
        int a = nxt[i][j].f,b = nxt[i][j].s;
        i = a;
        j = b;

    }

    cout<<res<<'\n';


    return 0;
}


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

int main() {

    int n,k;
    cin >> n >> k;
    vector<int> stick(n);

    for(int i = 0; i < n; i++){
          cin >> stick.at(i);
    }

    sort(stick.begin(), stick.end(), greater<int>());

    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += stick.at(i);
    }

    cout << sum << endl;

}



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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

typedef long long ll;
typedef pair<int, int> pii;

const int N = 6003;
int dp1[N][N];
int dp2[N][N];
int w[N], v[N];
int n, T;


int main(){
    fcin;

    cin >> n >> T;
    vector<pii> a;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }

    int ans = 0;

    for(int i = 1; i <= n; i++){
        for(int t = 1; t <= T - 1; t++){
            dp1[i][t] = dp1[i-1][t];
            if(t >= w[i]) dp1[i][t] = max(dp1[i][t], dp1[i-1][t - w[i]] + v[i]);
        }
    }

    for(int i = n; i >= 1; i--){
        for(int t = 1; t <= T - 1; t++){
            dp2[i][t] = dp2[i+1][t];
            if(t >= w[i]) dp2[i][t] = max(dp2[i][t], dp2[i+1][t - w[i]] + v[i]);
        }
    }

    for(int i = 1; i <= n; i++){
        for(int t = 1; t <= T - 1; t++){
            ans = max(ans, dp1[i-1][t] + dp2[i+1][T-1-t] + v[i]);
        }
    }

    cout << ans << endl;

    return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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; }

int main() {

	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] lots = new int[w];

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

        for (int i = 0; i < n; i++) {
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;

            int c;

            c = lots[a];
            lots[a] = lots[b];
            lots[b] = c;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(lots[i]);
        }

        sc.close();
    }
}


Measured memory_bytes: 26148
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
int dp[4000][7000];
int a[4000],b[4000];
int main()
{
	int n,t; cin>>n>>t;
	vector<pair<int,int> > p;
	for(int i=0;i<n;i++) {int t1,t2; cin>>t1>>t2; p.push_back(make_pair(t1,t2));}
	sort(p.begin(),p.end());
	for(int i=0;i<n;i++) a[i+1]=p[i].first;
	for(int i=0;i<n;i++) b[i+1]=p[i].second;
	//for(int i=1;i<=n;i++) cout<<a[i]<<" "<<b[i]<<endl;
	for(int i=1;i<7000;i++) dp[0][i]=-1000000000; dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<7000;j++) dp[i][j]=dp[i-1][j];
		for(int j=0;j<7000;j++) if(j>=a[i] && j-a[i]<t) dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]+b[i]);
	}
	int res=0;
	for(int i=0;i<7000;i++) res=max(res,dp[n][i]);
	cout<<res;
}

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

public class Program
{

    public void Proc()
    {
        int len = int.Parse(Reader.ReadLine());

        int[] items = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int[] idxs = new int[len];
        int[] subtotal = new int[len];

        long ans = 0;
        for (int i = 0; i < len; i++) {
            if(i==0) {
                idxs[0] = 0;
                subtotal[0] = items[0];
            } else {
                idxs[i] = idxs[i - 1];
                subtotal[i] = subtotal[i - 1] - items[i - 1];
            }
            int end = idxs[i];
            int sub = subtotal[i];
            for (int j = idxs[i] + 1; j < len; j++) {
                int sum = sub + items[j];
                int xor = sub ^ items[j];
                if(sum != xor) {
                    break;
                }
                sub = xor;
                end = j;
            }
            subtotal[i] = sub;
            idxs[i] = end;
            ans += (end - i + 1);
        }
        Console.WriteLine(ans);

    }


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 33488
var
    n,i,j:longint;
    s:array[0..101] of string;
begin
    readln(n);
    readln(s[1]);
    for i:=2 to n do
        begin
            readln(s[i]);
            for j:=1 to i-1 do
                if s[j]=s[i] then 
                    begin
                        writeln('No');
                        exit;
                    end;
            if s[i][1]<>s[i-1][length(s[i-1])] then 
                begin
                    writeln('No');
                    exit;
                end;
        end;
    writeln('Yes');
end.

Measured memory_bytes: 128
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;

int main() {
  stack<int> S;
  int a, b;
  char s[30];
  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(a + b);
    } else if (s[0] == '-') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(b - a);
    } else if (s[0] == '*') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(a * b);
    } else {
      S.push(stoi(s));
    }
    if(getchar() == '\n') {
      cout << S.top() << endl;
      return 0;
    }
  }
}


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

int main()
{
	string s;
	cin >> s;
	map<char, bool> M;
	for (auto c : s)
	{
		M[c] = 1;
	}
	for (int i = 0; i < 26; ++i)
	{
		if (!M[(char)('a' + i)])
		{
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

ll pos[100000];
vector<pair<int,int>> v[100000];

bool dfs(int k){
    for(auto p:v[k]){
        int l=p.first;
        int d=p.second;
        if(pos[l]==LINF){
            pos[l]=pos[k]+d;
            if(!dfs(l))return false;
        }
        else if(pos[l]!=pos[k]+d){
            return false;
        }
    }
    return true;
}

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        --l,--r;
        v[l].push_back({r,d});
        v[r].push_back({l,-d});
    }
    fill(pos,pos+n,LINF);
    bool ans=true;
    for(int i=0;i<n;i++){
        if(pos[i]==LINF){
            pos[i]=0;
            if(!dfs(i)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


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

int main() {
  int N, K, d;
  cin >> N >> K;
  vector<int> A(N, 0);

  for(int l = 0; l < K; ++l){
    cin >> d;
    for(int i = 0; i < d; ++i){
      int t;
      cin >> t;
      ++ A.at(t-1);
    }
  }
  
  int ans = 0;
  for(int i = 0; i < N; ++i){
    if(A.at(i) == 0) ++ ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
S=input()
N=len(S)
if N%2==1:
    L=S[0:N//2:1]
    R=S[-1:N//2:-1]
else:
    L=S[0:N//2:1]
    R=S[-1:N//2-1:-1]
ans=0
for i in range(N//2):
    if L[i]!=R[i]:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int a,b,c  ;
    cin >> a >> b >> c ; 

    if(a<b) swap(a,b) ;
    if(a<c) swap(a,c) ;
    //cout << a << b << c << endl ;
    int ans = (a-b)/2 + (a-c)/2 ;
    //cout << ans << endl ;
    int m = a ;
    int m_1 = a + 1 ;

    if(3*m%2==(a+b+c)%2)
        cout << (3*m-a-b-c)/2 << endl ;
    else
        cout << (3*(m+1)-a-b-c)/2 << endl ;
    
    return 0 ;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n==3 || n==5 || n==7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(s):
  res = 0
  cnt = 0
  for i in range(3):
    if s[i] == "R":
      cnt += 1
    else:
      res = max(res,cnt)
      cnt = 0
  res = max(res,cnt)

  return res



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9040
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd
int main()
{
    int n,i;
    double a,b=0.0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        b += 1.0/a;
    }
    cout << 1.0/b;
}

Measured memory_bytes: 256