akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;

deque<int> que;
int dist[SIZE];

int main(){
	int k;
	cin>>k;
	for(int i=0;i<k;i++) dist[i]=INF;
	dist[1]=1;
	que.push_back(1);
	while(!que.empty()){
		int u=que.front();
		que.pop_front();
		if(dist[(u*10)%k]>dist[u]){
			dist[(u*10)%k]=dist[u];
			que.push_front((u*10)%k);
		}
		if(dist[(u+1)%k]>dist[u]){
			dist[(u+1)%k]=dist[u]+1;
			que.push_back((u+1)%k);
		}
	}
	cout<<dist[0]<<endl;
}


Measured memory_bytes: 896
#include <stdio.h>

int main()
{
	int N, K, xi, i, sum;
	int half;
	scanf("%d", &N);
	scanf("%d", &K);
	half = K/2;
	sum = 0;
	
	for(i=0; i<N; i++)
	{
		scanf("%d", &xi);
		if(xi <= half) sum += xi*2;
		else           sum += (K -xi)*2;
	}
	
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct Edge {
  int t,next;
  Edge() {}
  Edge(int a,int b):t(a),next(b) {}
}; 

Edge e[200005];
int head[100005];

int f[100005],g[100005],ans;

void dfs(int x,int fa) {
  int sum=0;
  for(int i=head[x];i;i=e[i].next)
    if (e[i].t!=fa) {
    	int u=e[i].t;
    	dfs(u,x);
    	sum|=(g[x]&g[u]);
    	g[x]|=g[u];
	}
  for(int i=0;i<30;i++)
    if (!((1<<i)<sum)&&!(g[x]&(1<<i))) {
    	f[x]=i;
    	break;
	} 
  g[x]=((g[x]>>f[x]<<f[x])|(1<<f[x]));
  ans=max(ans,f[x]);
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[2*i-1]=Edge(y,head[x]);
  	head[x]=2*i-1;
  	e[2*i]=Edge(x,head[y]);
  	head[y]=2*i;
  }
  dfs(1,0);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<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 k;

int main(void){
    cin >> k;
    string s = "ACL";
    rep(i, k) cout << s;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    String[] array = new String[n];
		    
		    for(int i = 0; i < n; i++) 
		    {
		    	array[i] = scanner.next();
		    }
		    int matigai = 0;
		    
		    for(int i = 0; i < n - 1; i++) 
		    {
		    	if(array[i].substring(array[i].length() - 1).equals(array[i+1].substring(0,1))) 
		    	{
		    		
		    	}
		    	else 
		    	{
		    		matigai++;
		    	}
		    }
		    for(int i = 0; i < n; i++) 
		    {
		    	for(int j = 0; j < i; j++) 
		    	{
		    		if(array[i].equals(array[j])) 
		    		{
		    			matigai++;
		    		}
		    	}
		    }
		    
		    if(matigai == 0) 
		    {
		    	System.out.println("Yes");
		    }
		    else 
		    {
		    	System.out.println("No");
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int m = 1e9+7; 
int dp[1001][1001];
int sol(vector<vector<char>> &s, int i, int j)
{
    int h = s.size();
    int w = s[0].size();
    if(i <0 || i>=h || j<0 || j>=w)
        return 0;
    if(i == h-1 && j == w-1)
        return 1;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i][j] == '#')
        return 0;
    return dp[i][j] = (sol(s,i+1,j)%m + sol(s, i,j+1)%m)%m;
    
}

int main() 
{
    int h , w;
    cin>>h>>w;
    vector<vector<char>> s(h, vector<char>(w));
    vector<vector<int>> dp(h, vector<int>(w,0));
    // memset(dp, 0, sizeof(dp));
    for(int i = 0; i<h; i++)
    {
        for(int j = 0; j<w; j++)
            cin>>s[i][j];
    }
    for(int i = 0; i<h; i++)
    {
        if(s[i][0] == '.')
            dp[i][0] = 1;
        else
            break;
    }
    for(int i = 0; i<w; i++)
    {
        if(s[0][i] == '.')
            dp[0][i] = 1;
        else
            break;
    }
        
    for(int i = 1; i<h; i++)
    {
        for(int j = 1; j<w; j++)
        {
            if(s[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j]%m+dp[i][j-1]%m)%m;
            
        }
    }
    
    // for(auto i : dp)
    // {
    //     for(auto j : i)
    //     {
    //         cout<<j<<" ";
    //     }
    //     cout<<"\n";
    // }
    
    
    cout<<dp[h-1][w-1];
	return 0;
}


Measured memory_bytes: 8548
// 解説写経理解する
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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; }
const ll INF = 1LL << 60;

//Write From this Line

int N;

void dfs(string s, char mx) {
	if(s.length() == N){
		printf("%s\n" , s.c_str());
	} else {
		for (char c = 'a'; c <= mx; c++) {
			dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
		}
	}
}
int main()
{
	cin >> N ;
	dfs("", 'a');
	return 0 ;

}


Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;

const int N = 1 << 17;
vector<int> g[N];
int dp[N];

int f(int u) {
	auto &x = dp[u];
	if (x == -1) {
		x = 0;
		trav(v, g[u]) ckmax(x, 1 + f(v));
	}
	return x;
}

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

	int n, m; cin >> n >> m;
	rep(i, 0, m) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v);
	}
	rep(u, 0, n) dp[u] = -1;
	int ans = 0;
	rep(u, 0, n) ckmax(ans, f(u));
	cout << ans;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	stringstream s1;
	string s = "";
	s1.clear();
	for(int i = a; i <= b; i++)
	{
		s1 << i;
		s1 >> s;
		string rev = s;
		reverse(rev.begin(), rev.end());
		if(rev == s) cnt++;
		s1.clear();
		s = "";
	}
	cout << cnt;
}

Measured memory_bytes: 900
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
int ans=0;
signed main(){
    int n,m; cin >> n>>m;
    cout<<((n-m)*100+1900*m)*(int)pow(2,m)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位


int main(void) {
    ll a, b, c, k;
    cin  >> a >> b >> c >> k;
    ll ans = 0;
    if(k <= a+b) {
        if(a>=k) ans = k;
        else ans = a;
    }
    else if(k>a+b){
        ll d = k-a-b;
        ans = a-d;
    //    cout << d << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;

class Program
{
    public static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        if (n == 22) Console.WriteLine("Christmas Eve Eve Eve");
        else if (n == 23) Console.WriteLine("Christmas Eve Eve");
        else if (n == 24) Console.WriteLine("Christmas Eve");
        else Console.WriteLine("Christmas");
    }
}

Measured memory_bytes: 13140
n = gets.chomp.to_i
n.times{
  x,y,w,h = gets.split(" ").map{|x| x.to_i}
  count = 0
  cats = gets.chomp.to_i
  cats.times{
    cx,cy = gets.split(" ").map{|x| x.to_i}
    count +=1 if cx.between?(x,x+w) && cy.between?(y,y+h)
  }
  p count
}

Measured memory_bytes: 8760
h, w = map(int, input().split())
s = [[] for _ in range(h+2)]
s[0] = ["." for _ in range(w+2)]
s[h+1] = ["." for _ in range(w+2)]
for i in range(1, h+1):
    s[i].append(".")
    line = list(input())
    for j in range(w):
        s[i].append(line[j])
    s[i].append(".")

def bomb(x,y):
    if s[y][x] == "#":
        return 1
    else:
        return 0

for y in range(1,h+1):
    for x in range(1,w+1):
        if s[y][x] == ".":
            s[y][x] = bomb(x-1,y-1) + bomb(x,y-1) + bomb(x+1,y-1) + bomb(x-1,y) + bomb(x+1,y) + bomb(x-1,y+1) + bomb(x,y+1) + bomb(x+1,y+1)

for i in range(1,h+1):
    for j in range(1,w):
        print(s[i][j], end = "")
    print(s[i][w])

Measured memory_bytes: 45420
#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;


int cmp(const void *x, const void *y);

ll x, y, z;
ll k;
ll a[1005];
ll b[1005];
ll c[1005];
ll ab[1000 * 1000 + 5];
ll ab_n;
ll sum[3000 * 3000 + 5];
ll sum_n;

int main()
{
	scanf("%lld %lld %lld %lld", &x, &y, &z, &k);
	for (ll i = 0; i < x; i++) {
		scanf("%lld", &a[i]);
	}
	for (ll i = 0; i < y; i++) {
		scanf("%lld", &b[i]);
	}
	for (ll i = 0; i < z; i++) {
		scanf("%lld", &c[i]);
	}

	for (ll i = 0; i < x; i++) {
		for (ll j = 0; j < y; j++) {
			ab[ab_n] = a[i] + b[j];
			ab_n++;
		}
	}

	qsort(ab, ab_n, sizeof(ll), cmp);
	qsort(c, z, sizeof(ll), cmp);

	for (ll i = 0; i < min(ab_n, k); i++) {
		for (ll j = 0; j < z; j++) {
			sum[sum_n] = ab[i] + c[j];
			sum_n++;
		}
	}

	qsort(sum, sum_n, sizeof(ll), cmp);

	for (ll i = 0; i < k; i++) {
		printf("%lld\n", sum[i]);
	}

	return 0;
}

int cmp(const void *x, const void *y)
{
	if (*(ll *)x > *(ll *)y) {
		return -1;
	} else if (*(ll *)x == *(ll *)y) {
		return 0;
	} else {
		return 1;
	}
}


Measured memory_bytes: 56712
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 100005
mt19937 myrand(time(0));

int n,m;
bool vis[mx];
vector<int> adj[mx];

void dfs(int u){
    if(vis[u]) return;
    vis[u]=1;
    for(auto& v:adj[u]){
        if(!vis[v]) dfs(v);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]) ans++,dfs(i);
    }
    cout<<ans-1<<endl;
    return 0;
}

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

struct node
{
	int key;
	node* lc, * rc, * p;
};

node* root = 0;

void insert(int x)
{
	node* pre = root;        //设当前节点为根，以根为起点
	node* temp = pre;        //用来保存当前节点的临时指针

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = 0;     
	in->rc = 0;     

	while (pre != 0)
	{
		temp = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}
	pre = temp;

	in->p = pre;
	if (pre == 0)
		root = in;
	else
	{
		if (in->key < pre->key)
			pre->lc = in;
		else
			pre->rc = in;
	}
}

void Inorder(node* r)
{
	if (r->lc != 0)
		Inorder(r->lc);

	cout << " " << r->key;

	if (r->rc != 0)
		Inorder(r->rc);
}

void Preorder(node* r)
{
	cout << " " << r->key;

	if (r->lc != 0)
		Preorder(r->lc);
	if (r->rc != 0)
		Preorder(r->rc);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, x;
	string p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p;

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 26600
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>
#include <queue>

using namespace std;


int main() {
    int n; cin >> n;
    int k; cin >> k;
    vector<int> x(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i];
    }

    vector<int> dists(n- k + 1);
    for(int i = 0; i < n - k + 1; ++i){
        dists[i] = (x[i + k - 1] - x[i]) + min( abs(x[i]), abs(x[i + k - 1]));
    }

    sort(dists.begin(), dists.end());

    cout << dists[0] << "\n";

    return 0;
}

Measured memory_bytes: 768
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)

def main():
    n = int(input())
    s, t = input().split()
    ans = ""
    for i in range(n):
        for j in range(2):
            if j == 0:
                ans += s[i]
            else:
                ans += t[i]
    print(ans)

    
    

        


if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
N = int(input())
A = [[],[]]
A[0] = [int(_) for _ in input().split()]
A[1] = [int(_) for _ in input().split()]

totals = []
for j in range(N):
    totals.append(sum(A[0][0:j+1]) + sum(A[1][j:]))

print(max(totals))

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

map<int,int>mp;

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int counter=0;
    for(int i=0;i<n;i++)
    {
        if(mp[arr[i]]==0)
        {
            mp[arr[i]]=1;
        }
        else
        {
            counter++;
            break;
        }
    }
    if(counter==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define EPS 1.0e-9
#define PI acos(-1.0)
#define INF 30000000
#define MOD 1000000007
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define pai pair<int,int>
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
 int n;
 cin >> n;
 int ou=0;
 int four=0;
 int ji=0;
 int x;
 for(int i=1;i<=n;i++)
 {
        scanf("%d",&x);
        if(x%2==1)
        ji++;
        else
        {
        ou++;
        if(x%4==0)
        four++;
        }
 }
 if(four==ji-1&&ou==four)
 {
        cout<<"Yes"<<endl;
        return 0;
 }
 if(four>=ji)
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) {
        --a;
    }
    if (u == t) {
        --b;
    }
    cout << a << " " << b << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000001

typedef long long int lli;

long long int Gcd(int x, int y)
{
  if (y == 0)
    return x;
  else
    return Gcd(y, x % y);
}

int main(void)
{
  int n, a[MAX];

  scanf("%d", &n);
  rep(i, n)
  {
    scanf("%d", &a[i]);
  }

  int first[MAX], second[MAX];
  first[0] = a[0];
  second[n - 1] = a[n - 1];
  for (int i = 1; i < n; i++)
  {
    first[i] = Gcd(first[i - 1], a[i]);
    second[n - 1 - i] = Gcd(second[n - i], a[n - 1 - i]);
  }

  int max = second[1];
  for (int i = 1; i < n - 1; i++)
    max = max(max, Gcd(first[i - 1], second[i + 1]));
  max = max(max, first[n - 2]);
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N, A;
	cin >> N >> A;
	vector<ll> v(N);
	ll max_sum = 0, min_sum = 0;
	rep(N){
		cin >> v[i];
		v[i] -= A;
		if(v[i] >= 0){
			max_sum += v[i];
		}else{
			min_sum += v[i];
		}
	}
	
	map<ll, ll> dp[N];
	dp[0][v[0]]++;
	reppp(i, 1, N-1){
	    dp[i][v[i]]++;
		reppp(j, min_sum, max_sum){
			if(v[i] == 0){
				if(j == 0){
					dp[i][0] += dp[i-1][0] * 2;
				}else{
					dp[i][j] += dp[i-1][j] * 2;
				}
			}else{
				dp[i][j] += dp[i-1][j-v[i]] + dp[i-1][j];
			}
		}
	}
	/*
	rep(N){
		cout << v[i] <<  " ";
	}
	cout << endl;
	rep(N){
	    reppp(j, min_sum, max_sum){
		    printf("%2d ", dp[i][j]);
        }
        cout << endl;
	}
	*/
	cout << dp[N-1][0];
}


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

int main()
{
  string s;
  cin >> s;
  for (int i=0; i<3; i++) {
    if (s.at(i) == '1') s.at(i) = '9';
    else s.at(i) = '1';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def D(n,d):
  c=0
  while n>0:
    c=c+n//d
    n=n//d
  return c

A=primes(1000)
P=[[0]*2 for i in range(len(A))]
for i in range(len(A)):
  P[i][0]=A[i]
n=int(input())
mod=10**9+7
for j in range(len(A)):
  P[j][1]=P[j][1]+D(n,A[j])
ans=1
for i in range(len(A)):
  ans=ans*(P[i][1]+1)%mod
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
const int mod = 998244353;
const int inf = 1e9+7;

struct node {
    int l, r;
    inline void read() {
        scanf("%d%d", &l, &r);
    }
    inline bool operator < (const node &p) const {
        return l == p.l ? r < p.r : l < p.l;
    }
}a[maxn];
int n;

int l1[maxn], l2[maxn], r1[maxn], r2[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        a[i].read();
    sort(a + 1, a + 1 + n);
    r1[0] = r2[n + 1] = inf;
    for (int i = 1; i <= n; ++i) l1[i] = max(a[i].l, l1[i-1]), r1[i] = min(a[i].r, r1[i-1]);
    for (int i = n; i >= 1; --i) l2[i] = max(a[i].l, l2[i+1]), r2[i] = min(a[i].r, r2[i+1]);
//    l1[1] = a[1].l, r1[1] = a[1].r;
//    l2[n] = a[n].l, r2[n] = a[n].r;
//    for (int i = 2; i <= n; ++i) l1[i] = max(a[i].l, l1[i-1]), r1[i] = min(a[i].r, r1[i-1]);
//    for (int i = n-1; i >= 1; --i) l2[i] = max(a[i].l, l2[i+1]), r2[i] = min(a[i].r, r2[i+1]);

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans,
               max(i<n?max(0, r1[i] - l1[i] +1) + max(0, r2[i+1] - l2[i+1] + 1):0,
                       a[i].r - a[i].l + 1 + max(0, min(r1[i-1], r2[i+1]) - max(l1[i-1], l2[i+1]) + 1)
                       )
                );
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

#define FOR(x,z,n) for(int x=z;x<n;x++)
#define mp make_pair
typedef long long ll;
typedef pair<int, int> iPair;

int main() {
	ll x, value = 100, c=1;
	cin >> x;
	while (true){
		value *= 1.01;
		if (value >= x) { break; }
		c++;
	}
	cout << c;
	
}


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

int main() {
	vector<int> x(5, 0);
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

vector<char> S;
int num[4];
int res=0;

bool dfs(int i,int sum,int pat){
    if(i == 4){
        if(sum == 7){
            res = pat;
            return true;
        }
        return false;
    }

    return dfs(i+1,sum-num[i],pat*2) || dfs(i+1,sum+num[i],pat*2+1);

}

int bin(int x){
    int b=1;
    REPI(x)
        b*=2;
    return b;
}
    
int main(){
    char buf;
    
    while(1){
        scanf("%c",&buf);
        if(buf=='\n')
            break;
        S.push_back(buf);
    }

    REPI(4){
        num[i] = S[i] - '0';
    }
    
    dfs(1,num[0],0);

    REPI(3){
        printf("%d",num[i]);
        if(res/bin(2-i) == 1)
            printf("+");
        else
            printf("-");
        res%=bin(2-i);
    }

    printf("%d=7\n",num[3]);
    
    return 0;
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	ansL = [[] for i in range(10)]
	ansL[0].append(["a", 1])
	for i in range(N - 1):
		n = len(ansL[i])
		for j in range(n):
			for k in range(ansL[i][j][1]):
				ansL[i + 1].append([ansL[i][j][0] + chr(97 + k), ansL[i][j][1]])
			ansL[i + 1].append([ansL[i][j][0] + chr(97 + ansL[i][j][1]), ansL[i][j][1] + 1])

	n = len(ansL[N - 1])
	for i in range(n):
		print(ansL[N - 1][i][0])
	



if __name__ == '__main__':
	main()

Measured memory_bytes: 28364
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
a = b = 0
for k,v in sorted(ctr.items(),reverse=True):
    if v == 1: continue
    if not a:
        a = k
        if v >= 4:
            print(a*a)
            exit()
    elif not b:
        b = k
        print(a*b)
        exit()
print(0)


Measured memory_bytes: 21412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const int N = 1e5 + 10;
ll n,m;
ll v[N];
ll fact[N];
ll mul(ll a, ll b) {
    if(a < 0) a += MOD;
    if(b < 0) a += MOD;
    return ( (a % MOD) * (b % MOD) ) % MOD;
}
ll add(ll a, ll b) {
    if(a < 0) a += MOD;
    if(b < 0) a += MOD;
    return ( (a % MOD) + (b % MOD) ) % MOD;
}
ll subs(ll a, ll b) {
    return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
ll bpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) {
            ret = mul(a, ret);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}
ll inv(ll a) {
    return bpow(a, MOD - 2);
}
ll comb(ll a, ll b) {
    ll num = fact[a];
    ll den = mul(fact[a - b], fact[b]);
    ll i = inv(den);
    ll ret = mul(num, i);
    return ret;
}
void getf() {
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < N; ++i) {
        fact[i] = mul(fact[i - 1], i);
    }
}
int main() {
    getf();
    cin>>n>>m;
    for(int i = 0; i < n; ++i) {
        cin>>v[i];
    }
    sort(v, v + n);
    vector<ll> q;
    ll tempn = n - 1;
    ll tempm = m - 1;
    while(tempn >= tempm) {
        ll c = comb(tempn, tempm);
        q.emplace_back(c);
        tempn--;
    }
    int sz = (int) q.size() - 1;
    ll forw = 0, back = 0;
    for(int i = 0, k = 0; i < n; ++i, ++k) {
        ll mt = mul(v[i], q[k]);
        forw = add(forw, mt);
        if(k == sz) break;
    }
    for(int i = n - 1, k = 0; i >= 0; --i, ++k) {
        ll mt = mul(v[i], q[k]);
        back = add(back, mt);
        if(k == sz) break;
    }
    ll ans = subs(back, forw);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
vector<int> prime(0);
const int M=1000;

void primeGeneration(){
  vector<bool> number(M,true);
  for(int i=2;i*i<M;i++){
    for(int j=i+i;j<=M;j+=i){
      number[j]=false;
    }
  }
  for(int i=2;i<M;i++){
    if(number[i])prime.push_back(i);
  }
};

void factorization(vector<int> &num,vector<int> &pow,int N){
  int n=0,k=-1;
  int rn=-1;
  for(int i=0;i<M;i++){
    num[i]=0;pow[i]==0;
  }
  while(true){
    if(N%prime[n]==0){
      if(rn!=n){
        k++;
        num[k]=prime[n];
      }
      pow[k]++;
      N/=prime[n];
      rn=n;
    }else{
      n++;
    }
    if(N==1)break;
    if(prime[n]*prime[n]>N){
      bool ne=true;
      for(int i=0;i<=k;i++){
        if(num[i]==N){
          pow[i]++;
          ne=false;
          break;
        }
      }
      if(ne){
        num[k+1]=N;
        pow[k+1]=1;
      }
      break;
    }
  }
};

int main() {
  primeGeneration();
  //for(int i=0;i<M;i++)cout<<prime[i]<<endl;
  int N;cin>>N;
  vector<int> pow(M,0);
  for(int i=2;i<=N;i++){
    vector<int> p(M,0);
    vector<int> n(M,0);
    factorization(n,p,i);
    int k=0;
    for(int j=0;j<prime.size();j++){
      //cout<<prime[j]<<" "<<n[k]<<endl;
      if(prime[j]==n[k]){
        pow[j]+=p[k];k++;
      }
    }
  }
  long cnt=1;
  for(int i=0;i<M;i++){
    cnt=(cnt*(pow[i]+1))%1000000007;
  }
  cout<<cnt<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>> p;
    rep(i,n){
        ll w1,v;
        cin>>w1>>v;
        p.push_back(make_pair(v,w1));
    }
    ll num=p[0].second;
    //最初に何個選ぶか決め打ち
    sort(all(p));
    reverse(all(p));
    /*rep(i,n){
      cout<<p[i].first<<" "<<p[i].second<<endl;}*/
    ll ans=0;
    //ll num=p[0].second;
    for (int i=1;i<n+1;i++){
        if (w<num*i){
            break;
        }
        else{
            ll w1=w-num*i;
            if (w1>=3*i){
                ll ans1=0;
                rep(j,i){
                    ans1+=p[j].first;
                }
                ans=max(ans1,ans);
                //cout<<ans<<endl;
            }
            else{
                ll dp[n+1][i+1][w1+1];
                rep(j,n+1){
                    rep(l,i+1){
                    rep(k,w1+1){
                        dp[j][l][k]=0;
                    }
                }}
                for (int j=1;j<n+1;j++){
                    for (int l=1;l<i+1;l++){
                        if (l>j){
                            continue;
                        }
                        else{
                    for (int k=0;k<w1+1;k++){
                        if (k>=p[j-1].second-num){
                            dp[j][l][k]=max(dp[j-1][l][k],dp[j-1][l-1][k-p[j-1].second+num]+p[j-1].first);
                        }
                        else{
                            dp[j][l][k]=dp[j-1][l][k];
                        }
                    }}
                }}
              
                /*rep(i,n+1){
                  rep(j,w1+1){
                    cout<<dp[i][j]<<" ";
                  }
                  cout<<endl;}*/
                ans=max(ans,dp[n][i][w1]);
                }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

        int main() {
          ll N, M;
          cin>> N >> M; 
          
          vector<ll>A(N);
          vector<ll>B(M); 
          vector<ll>C(M); 
          
          for(int i=0; i<N; i++){
              cin>> A.at(i); 
          }
          for(int i=0; i<M; i++){
              cin>> B.at(i); 
              cin>> C.at(i); 
          }
          
          vector<pair<int, int>> p(N+M);
          for(int i=0; i<N; i++){
              p.at(i) = make_pair( A.at(i), 1 );  
          }
          
          
          for(int i=0; i<M; i++){
              p.at(N+i) = make_pair( C.at(i), B.at(i) );  
          }
          
          
          
          sort(p.begin(), p.end());
          reverse(p.begin(),p.end()); 
          
          /*
          for(int i=0; i<N+M; i++){
              ll a,b;
              tie(a,b)=p.at(i);
              cout<< a <<" "<< b << endl;
          }
          */

          
          ll count=0; 
          ll answer=0;
          
          for(int i=0; i<N+M; i++){
              ll x,y;
              ll z; 
              tie(x,y)=p.at(i);
              if(y+count<=N){
                  answer= answer + x*y;
                  count+=y;
              }else{
                  z = N-count; 
                  answer= answer + x*z;
                  count+=z;
              }
          }
          
          cout<< answer << endl;
          
          
        }


Measured memory_bytes: 4224
#include<stdio.h>

void swap (int *x, int *y)
{
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

int main(){
  int N,i,j;
  int A[100];
  int count=0;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
	swap(&A[j],&A[j-1]);
	count++;
      }
    }
  }
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i<N-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
  int n,p[10];
  int sum = 0;
  int max = 0,index_max;
  scanf("%d",&n);
  for (int i = 0; i < n; ++i) scanf("%d",&p[i]);
  for (int i = 0; i < n; ++i)
  {
  	if(max < p[i]){
  		max = p[i];
  		index_max = i;
  	}
  }
  for (int i = 0; i < n; ++i)
  {
  	if(i == index_max)	sum += (p[i] / 2);
  	else	sum += p[i];
  }
  printf("%d\n", sum);
  return 0;
}

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

int main()
{
	int N; std::cin >> N;
	vector<int> A(N);
	for(int n=0; n<N; n++)
	{
		std::cin >> A[n];
	}
	std::sort(A.begin(), A.end());
	int val = A[0];
	int count = 1;
	std::vector<int> num;
	for(int n=1; n<N; n++)
	{
		if(A[n]==val) count++;
		else
		{
			num.push_back(count);
			val = A[n];
			count = 1;
		}
	}
	num.push_back(count);
//	for(auto &x: num) std::cout << x << " ";
	int n_even = 0;
	for(auto &x: num)
	{
		if(x%2==0)
		{
			n_even++;
		}
	}
	if(n_even%2==0) std::cout << num.size();
	else std::cout << num.size()-1;
	std::cout << std::endl;
	
	return 0;
}


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

int main()
{
    ll a, b, f=10, c, x, n, i, y=0;
    cin >> a >> b;
    n = b;
    while(1)
    {
        if(b/10!=0)
        {
            f = f*10;
            b = b/10;
        }
        else
        {
            break;
        }
    }
    c = ((a*f) + n);
    for(i=1;i<=10000;i++)
    {
        if(c==(i*i))
        {
            y = 1;
            break;
        }
    }
    if(y==0)
    {
        cout << "No\n";
    }
    else if(y==1)
    {
        cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  int Q = 5;
  vector<int> data(Q,0);
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    if(str[0] =='M')
    {
      data[0]++;
    }
    else if (str[0] == 'A')
    {
      data[1]++;
    }
    else if(str[0] == 'R')
    {
      data[2]++;
    }
    else if(str[0] == 'C')
    {
      data[3]++;
    }
    else if(str[0] == 'H')
    {
      data[4]++;
    }
  }
  int ANS = 0;
  for (int i = 0; i < 1<<Q; i++)
  {
    int COUNT = 0;
    for (int c = 0; c < Q; c++)
    {
      if(i&(1<<c))COUNT++;
    }
    if(COUNT == 3)
    {
      int MUL = 1;
      // DEBUG(i);
      for (int c = 0; c < Q; c++)
      {
        if(i&(1<<c))
        {
          MUL *= data[c];
        }
      }
      ANS += MUL;
      
    }
    
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define ll long long
ll n,a,b,c,d;
map<ll,ll>dp;
ll inf= 1000000000000000000LL;
ll dfs(ll x)
{
    if(x==0)return 0;
    ll res=inf;
    if(dp.find(x)!=dp.end())
        return dp[x];
    if(x<inf/d)
        res=x*d;
    for(int i=-4;i<=4;i++)
    {
        ll y=x+i;
        if(y%2==0&&abs(i)<2&&y/2<x&&y>=2)res=min(res,dfs(y/2)+a+d*abs(i));
        if(y%3==0&&abs(i)<3&&y/3<x&&y>=3)res=min(res,dfs(y/3)+b+d*abs(i));
        if(y%5==0&&y/5<x&&y>=5)res=min(res,dfs(y/5)+c+d*abs(i));
    }
    return dp[x]=res;
}
void solve()
{
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    printf("%lld\n",dfs(n));
}
int main()
{
    int t;
    cin>>t;
    while(t--) {
        dp.clear();
        solve();
    }
}

Measured memory_bytes: 4516
#include <stdio.h>

int
main(void)
{
	int N, X;
	scanf("%d%d", &N, &X);
	
	int i, D = 0, res = 1;
	for (i = 0; i < N; i++) {
		int L;
		scanf("%d", &L);
		D += L;
		if (D <= X)
			res++;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 128
//?????????????????£????????§????§??????????????????????
#include <stdio.h>

int n, A[50];

int solve(int i, int m){
  if ( m == 0 ){
    return 1;
  }
  if ( i >= n ){
    return 0;
  }
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, m, i;

   scanf("%d", &n);
  for( i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for( i = 0; i < q; i++){
    scanf("%d", &m);
    if( solve(0,m) ){
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int64_t dp[3010][3010][4];
int64_t v[3010][3010];
int main() {
	int r, c, K; cin >> r >> c >> K;
	for(int i = 0; i < K; ++i) {
		int y, x, vv; cin >> y >> x >> vv;
		--y, --x;
		v[y][x] = vv;
	}
	dp[0][0][0] = 0;
	dp[0][0][1] = v[0][0];
	for(int i = 0; i <= r; ++i) {
		for(int j = 0; j <= c; ++j) {
			for(int k = 0; k <= 3; ++k) {
				if(i + 1 <= r) {
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + v[i + 1][j]);
				}
				if(j + 1 <= c) {
					dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
					if(k + 1 <= 3) {
						dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + v[i][j + 1]);
					}
				}
			}
		}
	}
	int64_t ans = 0;
	for(int i = 0; i <= 3; ++i) {
		ans = max(ans, dp[r][c][i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 356216
N = int(input())
a = list(map(int,input().split()))
b = []
j = 0
for i in a:
	if i < 3200:
		b.append(int(i/400))
	if i >= 3200:
		j += 1
k = len(set(b))
if k == 0 and j > 0:
	k = 1
	j = j-1
print(k,k+j)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int N=100020;
int v[3],p[N],q[N];
int main(){
    int n;cin >> n;
    string s;
    for(int i=0;i<3;i++)cin >> v[i];
    for(int i=1;i<=n;i++){
        cin >> s;
        p[i]=s[0]-'A';
        q[i]=s[1]-'A';
    }
    for(int i=1;i<=n;i++){
        if(v[p[i]]>v[q[i]])swap(p[i],q[i]);
        else if(v[p[i]]==v[q[i]])
            if(i<n&&(q[i]==q[i+1]||q[i]==p[i+1]))swap(p[i],q[i]);
        if(!v[q[i]])return 0*printf("No\n");
        v[p[i]]++,v[q[i]]--;
    }
    puts("Yes");
    for(int i=1;i<=n;i++) printf("%c\n",'A'+p[i]);
    return 0;
}

Measured memory_bytes: 4500
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  string s = readStr;
  int l = s.length.to!int;

  if(s.count("o") + 15 - l >= 8){
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <iostream>

int main() {

  int A;
  int B;
  int C;

  std::cin >> A >> B >> C;

  int sum = 0;
  sum = A + B;

  if (sum >= C) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N,K;
    cin >> N>> K;
    vll A(N);
    rep(i,N) cin >> A[i];
    // bool ans = false;
    rep(i,N-K)
        if(A[i] < A[i+K])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
            
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 4840
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

MOD = int(1e9+7)

N, M = map(int, cin.readline().split())
x = list(map(int, cin.readline().split()))
y = list(map(int, cin.readline().split()))

def n2total(n):
    total = [0]*n
    cnt = 0
    for i in range((n+1)//2):
        cnt += 1 * (n-i*2)
        total[i] = total[n-1-i] = cnt
    return total

x_total = n2total(N-1)
# print(x_total)
y_total = n2total(M-1)
# print(y_total)
xlen = 0
for i in range(N-1):
    xlen += (x[i+1]-x[i])*x_total[i]
ylen = 0
for j in range(M-1):
    ylen += (y[j+1]-y[j])*y_total[j]

ans = xlen * ylen % MOD
print(ans)

Measured memory_bytes: 19308
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let p = read_vec::<usize>();
    let mut ans = false;

    let mut count = 0;
    for i in 0..n {
        if p[i] != i + 1 {
            count += 1;
        }
    }
    if count <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String[] S = new String[N];
        for(int i = 0; i < N; i++){
            S[i] = sc.next();
        }
        sc.close();
        long m = 0;
        long a = 0;
        long r = 0;
        long c = 0;
        long h = 0;
        for(int i = 0; i < N; i++){
            if(S[i].charAt(0) == 'M')
                m++;
            if(S[i].charAt(0) == 'A')
                a++;
            if(S[i].charAt(0) == 'R')
                r++;
            if(S[i].charAt(0) == 'C')
                c++;
            if(S[i].charAt(0) == 'H')
                h++;
        }
        long sum = 0;
        sum += m*a*r +
                m*a*c +
                m*a*h +
                m*r*c +
                m*r*h +
                m*c*h +
                a*r*c +
                a*r*h +
                a*c*h +
                r*c*h;

        System.out.println(sum);
    }
}

Measured memory_bytes: 51312
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%lld%lld", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        ll a,b;
        while(~getII(a,b)){
                ll c,d;
                getII(c,d);
                ll cP=b/c-(a-1)/c;
                ll dP=b/d-(a-1)/d;
                ll cd=(c*d)/__gcd(c,d);
                ll cdP=b/cd-(a-1)/cd;
                ll tot=cP+dP-cdP;
//              printf("%lld %lld %lld %lld\n",cP,dP,cdP,tot);
                int cP2=0,dP2=0,cdP2=0;
                FE(i,a,b){
                        if(i%c==0) cP2++;
                        if(i%d==0) dP2++;
                        if(i%c==0&&i%d==0) cdP2++;
                }
//              printf("%d %d %d\n",cP2,dP2,cdP2);
                printf("%lld\n",(b-a+1)-tot);
        }
}

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

int main() {
	string s;
	ll k;
	cin >> s;
	cin >> k;

	int s_len = s.length();

	// 全てが同じ文字の場合
	bool same = true;
	for (int i = 1; i < s_len; ++i) {
		if (s.at(0) != s.at(i)) {
			same = false;
		}
	}
	if (same) {
		cout << s_len * k / 2 << endl;
		return 0;
	}

	// 文字列中に何回同じ文字があるか数える
	int cnt = 0;
	char c = s.at(0);
	for (int i = 1; i < s_len; ++i) {
		if (s.at(i) == c) {
			cnt++;
			c = ' ';
		} else {
			c = s.at(i);
		}
	}

	// 連結した場合の回数を数える
	string ss = s + s;
	int cnt2 = 0;
	c = ss.at(0);
	for (int i = 1; i < ss.length(); ++i) {
		if (ss.at(i) == c) {
			cnt2++;
			c = ' ';
		} else {
			c = ss.at(i);
		}
	}

	// 差を求める
	int sa = cnt2 - cnt;

	// 文字列回数分かける
	ll ans = cnt + (sa  * (k - 1));

	cout << ans << endl;

	return 0;
}

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

int main(){
    char s1[4];
    char s2[4];
    cin>>s1;
    getchar();
    cin>>s2;
    int count=0;
    for(int i=0;i<3;i++){
        if(s1[i]==s2[i])
        count++;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b, c; cin >> a >> b >> c;
	puts((a * 100 + b * 10 + c) % 4 == 0 ? "YES" : "NO");
}

Measured memory_bytes: 256