akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << '\n';
    return 0;
}


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

int main(){
  int N,x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int cnt = 0;
  int j = 0;
  while(x >= a.at(j)){
    x -= a.at(j);
    cnt++;
    j++;
    if(j == a.size()){
      if(x != 0){
        cnt--;
      }
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m,v,p;
    cin>>n>>m>>v>>p;

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

    sort(all(arr));

    vi pre(n+1);
    for(int i=0;i<n;++i)
        pre[i+1]=pre[i]+arr[i];

    int ans=0;
    for(int i=n-1;i>=0;--i)
    {
        if(arr[i]+m<arr[n-p])
            break;

        if((i+1)+p-1>=v)
        {
            ++ans;
            continue;
        }

        int pick=m*(v-(p-1)-(i+1));
        int req=((n-p)-(i+1)+1)*(arr[i]+m)-(pre[n-p+1]-pre[i+1]);

        //cout<<i<<" "<<pick<<" "<<req<<"\n";
        if(pick<=req)
            ++ans;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1792
n = int(input())
n_digit = len(str(n))
count = 0
for i in range(1, 10):
    for j in range(1, 10):
        # a:i[0-9]*j
        # b:j[0-9]*i
        a_count = 0
        b_count = 0
        for k in range(j, n+1, 10):
            k_str = str(k)
            if(i == int(k_str[0])):
                a_count += 1
        for k in range(i, n+1, 10):
            k_str = str(k)
            if(j == int(k_str[0])):
                b_count += 1
        count += a_count * b_count
print(count)


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

const int inf = 1e9;
const int N = 100010;

int n;
int h[N], cost[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	for (int i = 1; i <= n; ++i) {
		cost[i] = inf;
	}
	cost[1] = 0;
	for (int i = 2; i <= n; ++i) {
		if (i > 2) {
			cost[i] = min(cost[i], cost[i - 2] + abs(h[i] - h[i - 2]));
		} 
		cost[i] = min(cost[i], cost[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << cost[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	long long tempY;
	cin >> N >> tempY;
	int Y = tempY / 1000;

	for (auto i = 0; i <= N; ++i)
	{
		for (auto j = 0; j <= N - i; ++j)
		{
			auto sum = i * 10 + j * 5 + (N - i - j);
			if (sum == Y)
			{
				cout << i << " " << j << " " << (N - i - j) << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int search_max(int nums[]){
    int x = 0, max = nums[0];
    for(int i = 0; i < 3; i++){
        if(max < nums[i]){
            x = i;
            max = nums[i];
        }
    }
    return x;
}
int main(void){
    int k, nums[5], index, sum = 0;

    for(int i = 0; i < 3; i++){
        scanf("%d", &nums[i]);
    }

    scanf("%d", &k);
    index = search_max(nums);
    for(int i = 0; i < k; i++){
        nums[index] *= 2;
    }
    for(int i = 0; i < 3; i++){
        sum += nums[i];
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
       scanf("%d",&a[i]);
    }
    long long ret=0;
    int head=1,tail=1;
	int sum=0;
    for(tail=1;tail<=n;tail++){
    	while((sum^a[tail])!=sum+a[tail]){
        	sum^=a[head++];
		}
		//printf("%d  %d\n",head,tail);
    	sum^=a[tail];
        ret+=(tail-head+1);
    }
    printf("%lld",ret);
    return 0;
} 


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l, k;
    cin >> l >> k;
    ll dp[110] = {};
    dp[1] = 1;
    for(int i = 1; i <= l ; i++)
    {
        if(i == k) dp[i] += 1;
        if(i - 2 >= 0) dp[i] += dp[i - 2];
        if(i - k - 1 >= 0) dp[i] += dp[i - k - 1];
        //cout << dp[i] << endl;
    }
    ll ans = 0;
    for(int i = 0; i <= l; i++) ans += dp[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const ll INF = 2e18 ;
int n , W;
ll w[102], v[102]; 
ll dp[102][N];

ll solve(int n, ll W) {
	if(W < 0) return -2e9;
	if(W == 0) return 0LL;
	if(n == 0) return 0LL;
	ll &res = dp[n][W];
	if(~res) return res;
	//cout << n << ' '<< W << '\n';
	res = max(solve(n-1, W), solve(n-1, W-w[n]) + v[n]);
	return res ;
}

int main() {
    IOS;
    memset(dp, -1, sizeof dp);
    cin >> n >> W; 
    for(int i=1;i<=n;i++) cin >> w[i] >> v[i];
    cout << solve(n, W) << "\n";
	return 0 ;
}

// https://atcoder.jp/contests/dp/tasks






// // // https://codeforces.com/problemset/problem/474/E
// // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // https://codeforces.com/contest/475/problem/D


// https://www.spoj.com/problems/INS17M/
// https://www.codechef.com/SEPT18B/problems/ANDSQR
// 


Measured memory_bytes: 80000
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();

        int result = (a + b) * h / 2;

        System.out.println(result);
    }
}


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

#a = [[3, 2, 2, 4, 1], [1, 2, 2, 2, 1]]


ans = 0
for i in range(1,n+1):
  #print(a[0][0:i],a[1][i-1:n])
  x = sum(a[0][0:i]) + sum(a[1][i-1:n])
  ans = max( x , ans)

print(ans)

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

int main(void)
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])
    {
        cout <<"Yes"<<endl;
        return 0;
    }
    else if(s[1]==s[2]&&s[2]==s[3])
    {
        cout <<"Yes"<<endl;
        return 0;
    }
    cout <<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,l=0,r=0,i;
	string s;
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		if(s[i]=='('){
			++l;
		}else if(l){
			--l;
		}
	}
	for(i=(n-1); i>=0; --i){
		if(s[i]==')'){
			++r;
		}else if(r){
			--r;
		}
	}
	for(i=0; i<r; ++i){
		cout << "(";
	}
	cout << s;
	for(i=0; i<l; ++i){
		cout << ")";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

r = [False for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            r[i] = True
            break
c = [False for _ in range(w)]
for i in range(w):
    for j in range(h):
        if a[j][i] == '#':
            c[i] = True
            break
for i in range(h):
    if r[i]:
        s = ""
        for j in range(w):
            if c[j]:
                s += a[i][j]
        print(s)

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

int main()
{
  int n,m;
  cin>>n>>m;
  
  vector<vector<int>> vec(n,vector<int>(2));
  
  int acsum=0;
  int wasum=0;
  
  for(int i=0;i<m;i++)
  {
    int p;
    string s;
    cin>>p>>s;
    
    if(s=="AC")
    {
      if(vec.at(p-1).at(0)==0)
      {
        vec.at(p-1).at(0)++;
        acsum++;
        wasum+=vec.at(p-1).at(1);
      }
    }
    else
    {
      if(vec.at(p-1).at(0)==0)
      {
        vec.at(p-1).at(1)++;
      }
    }
  }
  
  
  cout<<acsum<<" "<<wasum<<endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		System.out.println(2 * G - R);
	}
}

Measured memory_bytes: 21844
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 0

#define MAXN 5001
typedef long long ll;
//vector< vector<ll> > t;
vector<ll> t[3];

int main() {
  ll n;
  cin >> n;
  vector<int> a(3);
  vector<int> b(3);
  forr(i,0,2)
    cin >> a[i];
  forr(i,0,2)
    cin >> b[i];

  if (DBG) cout << "hi2";

  forr(i,0,2) {
    t[i].resize(n+1);
    t[i][0] = 0;
    forr(j,1,n) t[i][j] = -1;
  }
  if (DBG) cout << "hi";

  ll mx = 0;
  forr(i,0,2) {
    int aa = a[i];
    int x = b[i]-a[i];
    forr(j,1,n) {
      ll tij = -1;
      if (i>0) tij = t[i-1][j];
      if (j >= aa && t[i][j-aa] != -1)
          tij = max(tij, t[i][j-aa]+x);
      t[i][j] = tij;
      mx = max(mx,tij);
    }
  }

  n += mx;

  forr(i,0,2) {
    t[i].resize(n+1);
    t[i][0] = 0;
    forr(j,1,n) t[i][j] = -1;
  }

  mx = 0;
  forr(i,0,2) {
    int bb = b[i];
    int x = a[i]-b[i];
    forr(j,1,n) {
      ll tij = -1;
      if (i>0) tij = t[i-1][j];
      if (j >= bb && t[i][j-bb] != -1)
          tij = max(tij, t[i][j-bb]+x);
      t[i][j] = tij;
      mx = max(mx,tij);
    }
  }

  cout << n+mx << endl;

}


Measured memory_bytes: 586368
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  if(a<0){
    if(b>0){
      cout<<"Zero"<<endl;
    }else{
      if(b==0)
	cout<<"Zero"<<endl;
      else{
	if(abs(a-b)%2==0)cout<<"Negative"<<endl;
	else cout<<"Positive"<<endl;
      }
    }
  }else{
    if(a!=0)
    cout<<"Positive"<<endl;
    else cout<<"Zero"<<endl;
  }
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<pair<int, int>>> s(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        for (int j = 0; j < A.at(i); j++)
        {
            int xij, yij;
            cin >> xij >> yij;
            xij--;
            s.at(i).push_back(make_pair(xij, yij));
        }
    }

    int res = 0;
    for (int h = 0; h < (1 << N); h++)
    {
        bitset<15> is_honest(h);
        bool valid = true;
        for (int i = 0; i < N; i++)
        {
            if (is_honest.test(i))
            {
                for (auto sij : s.at(i))
                {
                    int xij = sij.first, yij = sij.second;
                    if (yij == 0 && is_honest.test(xij))
                        valid = false;
                    if (yij == 1 && !is_honest.test(xij))
                        valid = false;
                }
            }
        }
        if (valid)
        {
            res = max(res, (int)is_honest.count());
        }
    }
    cout << res << endl;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1;i < s.size();i++) {
		if (s[i] != s[i-1]) {ans++;}
	}
	cout << ans << endl;
}

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

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n > k){
    cout << k * x + (n - k) * y;
    }
    else cout << n * x;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct UnionFind
{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

struct Edge
{
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator<(const Edge &e, const Edge &f)
{
    return e.cost > f.cost;
}

vector<int> dijkstra(const Graph &g, int s)
{
    vector<int> d(g.size(), INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s)); // P(dis, pos)
    while (!que.empty())
    {
        int dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if (d[v] < dist)
            continue;
        for (const auto &e : g[v])
        {
            if (d[e.to] <= d[v] + e.cost)
                continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v, c;
            cin >> v >> c;
            g[u].push_back(Edge{u, v, c});
        }
    }
    vector<int> res = dijkstra(g, 0);
    for (int i = 0; i < n; i++)
        cout << i << " " << res[i] << endl;
}



Measured memory_bytes: 9908
#include <iostream>

using namespace std;

int main()
{
	int arr[5],k;
	for(int i=0; i<5; i++)
		cin>>arr[i];

	cin>>k;
	int flag = 0;

	for(int i=0; i<4; i++)
	{
		for(int j=i+1; j<5; j++)
		{
			if((arr[j]-arr[i])>k)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			break;
	}

	if(flag==1)
		cout<<":(";
	else
		cout<<"Yay!";

						
}




Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

void aokidfs(vector<vector<int> > &G, vector<int> &v, int now, int cost){
    v[now]=cost;
    for(int to:G[now]){
        if(v[to]>=0) continue;
        aokidfs(G,v,to,cost+1);
    }
}

void takadfs(vector<vector<int> > &G, vector<int> &v, int now, int cost){
    v[now]=cost;
    for(int to:G[now]){
        if(v[to]>=0) continue;
        takadfs(G,v,to,cost+1);
    }
}


int main(){
    int n,u,v;
    cin>>n>>u>>v;
    u--; v--;
    vector<vector<int> > G(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> aoki(n,-1);
    vector<int> taka(n,-1);
    aokidfs(G,aoki,v,0);
    takadfs(G,taka,u,0);
    int ans=0;
    for(int i=0;i<n;i++){
        //cout<<"i="<<i<<":"<<aoki[i]<<","<<taka[i]<<endl;
        if(aoki[i]>taka[i]){
            ans=max(ans,aoki[i]);
        }
    }
    cout<<ans-1<<endl;
    
}

Measured memory_bytes: 12780
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var UF = new UnionFind(N);
		for(int i=0;i<M;i++) UF.Unite(A[i], B[i]);
		int ma = 0;
		for(int i=0;i<N;i++) ma = Math.Max(ma, UF.MemCnt(i));
		Console.WriteLine(ma);
		
	}
	int N, M;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	
	public UnionFind(UnionFind v){
		// copy constructor
		N = v.N;
		parent = new int[N];
		mem = new int[N];
		for(int i=0;i<N;i++){
			parent[i] = v.parent[i];
			mem[i] = v.mem[i];
		}
		compo = v.compo;
	}
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N = n_;
		parent = new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i] = i;
			mem[i] = 1;
		}
		compo = N;
	}
	
	public int Parent(int a){
		if(parent[a] == a)return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a == b)return;
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i == 0 ? "{0}" : " {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


Measured memory_bytes: 49724
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    set<string>s;
    string st;
    for(ll i=0;i<n;++i) {
        cin>>st;
        s.insert(st);
    }
    cout<<s.size();
    return 0;
}


Measured memory_bytes: 19276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<P>vec;
int n;
bool cmp(const P&a,const P&b){
	return a.fi+a.sc > b.fi+b.sc;
}
int main(){
	cin>>n;
	rep(i,n){
		int a,b; scanf("%d%d",&a,&b);
		vec.pb(mp(a,b));
	}
	sort(vec.begin(),vec.end(),cmp);
	ll ans = 0;
	rep(i,n){
		if(i%2 == 0) ans += vec[i].fi;
		else ans -= vec[i].sc;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	long long K;
	while(~scanf("%lld", &K)) {
		const int M = 8;
		const int X = 600;
		vector<vector<ll>> dp(X + 1, vector<ll>(M));
		rer(i, 0, X)
			dp[i][0] = 1;
		rep(i, X) {
			rep(j, M - 1)
				dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
		}
		vector<int> c(X + 1);
		for(int i = X; i >= 1; -- i) {
			c[i] = (int)(K / dp[i][M - 1]);
			K %= dp[i][M - 1];
		}
		string ans;
		rer(i, 1, X) {
			ans += "FESTIVA";
			rep(j, c[i])
				ans += 'L';
		}
		puts(ans.c_str());
	}
	return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using p32 = pair<i32, i32>;

i32 n;
vector<i32> a;
map<p32, i64> dp;

i64 dfs(i32 index, i32 use) {
    if (use == n / 2) return 0;
    if (index / 2 < use) return -INT64_MAX / 2;
    if ((n - index + 1) / 2 < n / 2 - use) return -INT64_MAX / 2;
    if (dp.find({index, use}) != dp.end()) return dp[{index, use}];
    return dp[{index, use}] = max(a[index] + dfs(index + 2, use + 1), dfs(index + 1, use));
}

int main() {
    cin >> n;
    a.assign(n, 0);
    for (auto& e : a) cin >> e;
    cout << dfs(0, 0) << endl;
}


Measured memory_bytes: 33072
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 2e5;
const int MXV = 0;
const LL MOD = 998244353;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

vector<int> bits(MXN, 0);

void update(int x, int val, int n)
{
    for (; x <= n; x += (x & (-x)))
    {
        bits[x] = max(bits[x], val);
    }
}

int query(int x)
{
    int ans = 0;
    for (; x > 0; x -= (x & (-x)))
    {
        ans = max(ans, bits[x]);
    }
    return ans;
}

int main()
{
    IOS;
    int n;
    cin >> n;
    vector<PII> data(n);
    vector<LL> dp(n + 1, 0);
    vector<int> res(n, 0);
    FOR(i, 0, n) { cin >> data[i].F >> data[i].S; }
    sort(data.begin(), data.end());
    dp[n] = 1;
    FORD(i, n - 1, 0 - 1)
    {
        res[i] = i;
        int pos = lower_bound(data.begin(), data.end(),
                              MP(data[i].F + data[i].S, 0)) -
                  data.begin() - 1;
        res[i] = max(res[i], query(pos + 1));
        update(i + 1, res[i], n);
        if(res[i] + 1 < (int)dp.size())
        {
            dp[i] = (dp[i + 1] + dp[res[i] + 1]) % MOD;
        }
        else
        {
            dp[i] = (dp[i + 1] + 1) % MOD;
        }
        // cout << i << ' ' << data[i].F + data[i].S << ' ' << pos << ' ' << res[i]
        //      << ' ' << dp[i] << '\n';
    }
    cout << dp[0] << '\n';
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N; cin >> N;
  LL x1 = 1, x2 = 1, x3 = 1, x4 = 1;
  for(int i = 0; i < N; ++i)  x1 = (x1 * 10LL) % kMod;
  for(int i = 0; i < N; ++i)  x2 = (x2 * 9LL) % kMod;
  for(int i = 0; i < N; ++i)  x3 = (x3 * 9LL) % kMod;
  for(int i = 0; i < N; ++i)  x4 = (x4 * 8LL) % kMod;

  x2 = (x2 + x3 - x4 + kMod) % kMod;
  cout << (x1-x2 + kMod)%kMod << endl;
  return 0;
}


Measured memory_bytes: 3580
while True:
	[H, W] = list(map(int, input().split()))

	if H == 0 and W == 0:
		break

	for i in range(H):
		for j in range(W):
			k = j
			if i % 2 == 0:
				k += 1

			if k % 2 == 0:
				print(".", end = "")
			else:
				print("#", end = "")

		print("")
	print("")

Measured memory_bytes: 8992
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

int main()
{
    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll sum = 0;
    for (ll i = 0; i <= N / R; i++)
    {
        for (ll j = 0; j <= N / G; j++)
        {
            ll remain = N - i * R - j * G;
            if (remain >= 0 && remain % B == 0)
            {
                sum += 1;
            }
        }
    }
    cout << sum << endl;
}

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

const int MOD = 1e9 + 7;







int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int A, B; cin >> A >> B;
  if (A > 12) cout << B << '\n';
  else if (A > 5) cout << B / 2 << '\n';
  else cout << 0 << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF 1<<20
using namespace std;

int main(){
  int n,m,s,e,c;

  while(true){
    cin >> n >> m;
    if(n+m == 0)break;
    int lst[n+1][n+1];
    int Graph[n+1][n+1];
    for(int i=0;i<n+1;i++)for(int j=0;j<n+1;j++){
	lst[j][i] = i==j?0:INF;
	Graph[i][j] = INF;
      }
    for(int i=0;i<m;i++){
      cin >> s >> e >> c;
      Graph[s][e] = Graph[e][s] = lst[s][e] = lst[e][s] = c;
    }

    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)lst[i][j] = min(lst[i][j],lst[i][k]+lst[k][j]);
    int cost = lst[1][n];
    for(int k=1;k<=n;k++){
      for(int i=1;i<=n;i++){
if(Graph[k][i] == INF)continue;
	for(int j=1;j<=n;j++){
	  if(Graph[k][i] != INF &&  Graph[k][j] != INF){	  
	    cost = min(cost,lst[1][i]+lst[j][n]);
	  }
	}
      }
    }
    cout <<  cost << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> v(5);
  int i;
  for(i=0;i<5;i++) cin >> v[i];
  for(i=0;i<5;i++){
    if(v[i]==0){
      cout << i+1 << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int k; cin >> k;
    queue<ll> q;
    rep(i, 9) q.push(i+1);
    rep(i, k-1) {
        ll x = q.front(); q.pop();
        ll r = x%10;
        if(r != 0) q.push(10*x+r-1);
        q.push(10*x+r);
        if(r != 9) q.push(10*x+r+1);
    }
    cout << q.front();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);
    ll n,k;
    cin>>n>>k;
    vi a(n);
    cin>>a;
    vi gt_bef(n);
    map<int,int> m;
    REP(i,n){
        for(auto&&p:m){
            if(p.F<=a[i])continue;
            gt_bef[i]+=p.S;
        }
        ++m[a[i]];
    }
    dprint(gt_bef);
    m.clear();
    vi gt_aft(n);
    REPR(i,n){
        for(auto&&p:m){
            if(p.F<=a[i])continue;
            gt_aft[i]+=p.S;
        }
        ++m[a[i]];
    }
    dprint(gt_aft);
    ll ans=0;
    REP(i,n){
        ans+=((k)*(k+1)/2)%MOD*gt_bef[i];
        ans+=((k-1)*(k)/2)%MOD*gt_aft[i];
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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 int mod = 1000000007;
struct mint {
    ll x; // using long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n + 1);
    cin>>as;

    combination comb(n + 10);
    vvl bs(n + 1);
    ll l, r;
    rep(i, n + 1) {
        bs[as[i]].push_back(i);
        if (bs[as[i]].size() == 2) {
            l = bs[as[i]][0];
            r = bs[as[i]][1];
            break;
        }
    }
    rep(i, n + 1) {
        mint ans = comb(n + 1, i + 1);
        if (i <= l + n - r) ans -= comb(l + n - r, i);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main(){
    double l;
    cin >> l;
    cout << fixed << setprecision(10);
    cout << (l/3)*(l/3)*(l/3) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
    	InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        while(true){
        	int ans = 0;
        	String[] input = br.readLine().split(" "); 
            int a = Integer.parseInt(input[0]);
            String op = input[1]; 
            int b = Integer.parseInt(input[2]);
            if(op.equals ("+")){
            	ans = a + b;
            }else if(op.equals ("-")){
            	ans = a - b;
            }else if(op.equals ("*")){
            	ans = a * b;
            }else if(op.equals ("/")){
            	ans = a / b;
            }else{
            	break;
            }
            System.out.println(ans);
        }
        
    }
}

Measured memory_bytes: 24332
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,A,B;
	scan(N);scan(A);scan(B);
	ll MAX=A+(N-1)*B,MIN=(N-1)*A+B;
	if(A>B||(A!=B&&N==1)) prin(0);
	else prin(MAX-MIN+1);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
	int res;
	if(m==0){return 1;}
	if(i>=n){return 0;}
	if(solve(i+1,m)==1){
		res=solve(i+1,m);
	}
	else if(solve(i+1,m-A[i])==1){
		res=solve(i+1,m-A[i]);
	}
	return res;
}
int main(void){
	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: 2128
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr = str.toCharArray();
		for(int i=0;i<cr.length;i++){
			if(Character.isLowerCase(cr[i])){
				System.out.print(Character.toUpperCase(cr[i]));
			}else{
				System.out.print(Character.toLowerCase(cr[i]));
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 16932
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int n,W;
long long v[105];
int w[105];
long long dp[105][100005];//i番目以降の品物から、重さの和がj以下のなるように選んだ時の和の最大値

void solve_dp()
{
    for (int j = 0;j <= W;j++){//n番目以降の品物はない
        dp[n][j] = 0;
    }
    
    //番号の残りが数ない方が、重さの和が小さい方が値が決まるのが早いから以下のように走査
    for (int i = n-1;i >= 0;i--){
        for (int j = 0;j <= W;j++){
            if (j < w[i]){
                dp[i][j] = dp[i+1][j];
            }
            else {
                dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[0][W] << endl;
}

int main()
{
    cin >> n >> W;
    for (int i = 0;i < n;i++){
        cin >> w[i] >> v[i];
    }
    
    solve_dp();
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a;
  string s;
  cin>>s>>a;
  char res='1';
  FOR(i,0,a){
    if(s[i]!='1'){
      res=s[i];
      break;
    }
  }

  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 1e10;
    for(int i = 0 ; i <= max(x,y)*2 ; i+=2){
        ll k = max((ll)0, x-i/2)* a + max((ll)0, y-i/2)*b+i*c;
        ans = min(ans, k);
    }

    cout << ans;
}

Measured memory_bytes: 256
(* O(n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let dp = Array.make n 0
let cost i j = abs @@ hs.(i) - hs.(j)
let _ =
  dp.(1) <- cost 0 1;
  for i = 2 to n - 1 do dp.(i) <- min (dp.(i - 1) + cost (i - 1) i) @@ dp.(i - 2) + cost (i - 2) i done;
  Printf.printf "%d\n" @@ dp.(n - 1)

Measured memory_bytes: 5760
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int n = 0,no;
	cin >> n;
	char mark;
	int card[4][15] = { 0 };
	for (int i = 0; i < n; i++){
		cin >> mark;
		cin >> no;
		switch (mark){
			case 'S':
				card[0][no] = 99;
				break;
			case 'H':
				card[1][no] = 99;
				break;
			case 'C':
				card[2][no] = 99;
				break;
			case 'D':
				card[3][no] = 99;
				break;
		}
	}
		for (int i = 0; i < 4; i++){
			for (int j = 1; j < 14; j++){
				if (card[i][j] != 99){
					switch (i){
					case 0:
						cout << "S " << j << endl;
						break;
					case 1:
						cout << "H " << j << endl;				
						break;
					case 2:
						cout << "C " << j << endl;
						break;
					case 3:
						cout << "D " << j << endl;
						break;

					}
				}
			}
		}
	
	return 0;
}

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

int main(){
	
	int n,m; cin>>n>>m;
	vector<bool> g(n,1);
	vector h(n,0);
	for(int i=0; i<n; i++) cin>>h.at(i);
	for(int i=0; i<m; i++){
		int a,b; cin>>a>>b;
		a--;b--;
		if(h.at(a)<=h.at(b)) g.at(a)=0;
		if(h.at(a)>=h.at(b)) g.at(b)=0;
		
	}
	int sum{};
	for(auto &&i:g){
		sum+=i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3788
object Main extends App {
	val N = scala.io.StdIn.readLong

	val a = N / 3L
	val b = N / 5L
	val c = N / 15L

	println(N*(N+1L)/2L - 3L*a*(a+1L)/2L - 5L*b*(b+1L)/2L + 15L*c*(c+1L)/2L )
}

Measured memory_bytes: 54644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		int h, m, s;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int S = Integer.parseInt(br.readLine());

		h = S / 3600;
		m = (S - h * 3600) / 60;
		s = S - (h * 3600 + m * 60);

		System.out.println(h + ":" + m + ":" + s );
	}
}

Measured memory_bytes: 24248
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String n = stdIn.next();
			int counter = 0;
			if(n.equals("0000")) {
				break;
			}
			if(n.equals("1111") || n.equals("2222") || n.equals("3333") || n.equals("4444") || n.equals("5555")
					||n.equals("6666") || n.equals("7777") || n.equals("8888") || n.equals("9999")) {
				System.out.println("NA");
				continue;
			}
			while(true) {
				if(n.equals("6174")) {
					break;
				}
				counter++;
				String L = "";
				String tmp = n.substring(0, 4);
				for(int i = 0; i < 4; i++) {
					for(int j = 9; j >= 0; j--) {
						if(tmp.charAt(0) == String.valueOf(j).charAt(0)) {
							L += tmp.substring(0, 1);
							tmp = tmp.substring(1, tmp.length());
							break;
						}
						else if(tmp.length() >= 2 && tmp.charAt(1) == String.valueOf(j).charAt(0)) {
							L += tmp.substring(1,2);
							tmp = tmp.substring(0,1) + tmp.substring(2,tmp.length());
							break;
						}
						else if(tmp.length() >= 3 && tmp.charAt(2) == String.valueOf(j).charAt(0)) {
							L += tmp.substring(2,3);
							tmp = tmp.substring(0,2) + tmp.substring(3,tmp.length());
							break;
						}
						else if(tmp.length() >= 4 && tmp.charAt(3) == String.valueOf(j).charAt(0)) {
							L += tmp.substring(3,4);
							tmp = tmp.substring(0,3);
							break;
						}
					}
				}
				tmp = n.substring(0, 4);
				String S = "";
				for(int i = 0; i < 4; i++) {
					for(int j = 0; j < 10; j++) {
						if(tmp.charAt(0) == String.valueOf(j).charAt(0)) {
							S += tmp.substring(0, 1);
							tmp = tmp.substring(1, tmp.length());
							break;
						}
						else if(tmp.length() >= 2 && tmp.charAt(1) == String.valueOf(j).charAt(0)) {
							S += tmp.substring(1,2);
							tmp = tmp.substring(0,1) + tmp.substring(2,tmp.length());
							break;
						}
						else if(tmp.length() >= 3 && tmp.charAt(2) == String.valueOf(j).charAt(0)) {
							S += tmp.substring(2,3);
							tmp = tmp.substring(0,2) + tmp.substring(3,tmp.length());
							break;
						}
						else if(tmp.length() >= 4 && tmp.charAt(3) == String.valueOf(j).charAt(0)) {
							S += tmp.substring(3,4);
							tmp = tmp.substring(0,3);
							break;
						}
					}
				}
				
				n = Integer.toString(Integer.parseInt(L) - Integer.parseInt(S));
				if(n.length() == 3) {
					n = "0" + n;
				}
				else if(n.length() == 2) {
					n = "00" + n;
				}
				else if(n.length() == 1) {
					n = "000" + n;
				}
			}
			System.out.println(counter);
		}
	}
}

Measured memory_bytes: 127644