akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

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

	vector< vector<int> > a(n, vector<int>(m));
	vector<int> b(m), c(n, 0);

	for (vector<int>::size_type i = 0; i < n; i++) {
		for (vector<int>::size_type j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (vector<int>::size_type i = 0; i < m; i++)
		cin >> b[i];

	for (vector<int>::size_type i = 0; i < n; i++) {
		for (vector<int>::size_type j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
		cout << c[i] << "\n";
	}
}

Measured memory_bytes: 1256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public struct AB
        {
            public int A;
            public int B;
        }

        int N;
        List<string> list = new List<string>();



        public void AddNext(string input, int count)
        {


            if (count == N)
            {
                list.Add(input + "1");
                list.Add(input + "0");
                return;
            }
            else
            {

                AddNext(input + "1", count + 1);
                AddNext(input + "0", count + 1);
            }

        }

        public void Calc()
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();


            if(K >= S.Length)
            {
                Console.WriteLine(S);
            }
            else
            {
                Console.WriteLine(S.Substring(0,K)+"...");

            }


            //var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();




        }


    }

}


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

class Edge
{
public:
	int src,dst,cap,rev,num,add;
	Edge(){}
	Edge(int s, int d, int cp, int r, int n, int a)
		:src(s),dst(d),cap(cp),rev(r),num(n), add(a)
	{}
};

const int INF = (1<<28);

typedef vector<vector<Edge> > Graph;

int dfs(int p, int T, int mf, Graph& graph, vector<int>& level, vector<bool>& finished)
{
	if(p==T) return mf;
	if(finished[p]) return 0;
	
	finished[p]=true;
	
	for(int i=0; i<graph[p].size(); i++)
	{
		Edge &e = graph[p][i];
		int next=e.dst, fw=e.cap;
		if(level[p] >= level[next]) continue;
		if(fw <=0 ) continue;
	
		int f=dfs(next, T, min(mf, fw), graph, level, finished);
		if(f>0)
		{
			finished[p]=false;
			graph[p][i].cap -= f;
			graph[next][e.rev].cap += f;

			return f;
		}
	}
	
	return 0;
}

int dinic(int S, int T, Graph& graph)
{
	bool end=false;
	int total=0;
	while(!end)
	{
		end=true;
		vector<int> level(graph.size(), -1);
		level[S]=0;
		
		queue<int> q;
		q.push(S);
		while(!q.empty())
		{
			int n=q.front(); q.pop();
			for(int i=0; i<graph[n].size(); i++)
			{
				Edge &e = graph[n][i];
				if(level[e.dst]!=-1) continue;
				if(e.cap <= 0) continue;
				level[e.dst]=level[n]+1;
				q.push(e.dst);
			}
		}
		
		if(level[T]==-1) break;
		
		vector<bool> finished(graph.size());
		while(1)
		{
			int fw=dfs(S, T, INF, graph, level, finished);
			if(fw<=0) break;
			
			total+=fw;
			end=false;
		}
	}
	
	return total;
}

void add_edge(int s, int d, int c, int n, int a, Graph& g)
{
	g[s].push_back(Edge(s,d,c,g[d].size()  , n, 0));
	g[d].push_back(Edge(d,s,c,g[s].size()-1, n, 1)); 
}

int main()
{
	int N,M,S,T;
	cin >> N >> M;

	Graph g(N);

	for(int i=0; i<M; i++)
	{
		int s,t;
		cin >> s >> t;
		add_edge(s-1, t-1, 1, i, 0, g);
	}

	cin >> S >> T;
	cout << dinic(S-1,T-1,g) << endl;

	vector<int> res;
	for(int i=0; i<N; i++)
	for(int j=0; j<g[i].size(); j++)
	{
		if(g[i][j].add == 1 && g[i][j].cap == 0)
			res.push_back(g[i][j].num);
	}

	cout << res.size() << endl;
	for(int i=0; i<res.size(); i++)
		cout << res[i] + 1 << endl;
}

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

using namespace std;
typedef long long ll;

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

	int ans = 1001001001;
	int double_c = c * 2;
	for(int i = 0; i <= 100000; i++){
		int temp;
		temp = i * double_c + a * max(0, x - i) + b * max(0, y - i);
		ans = min(ans, temp);	
	}

	cout << ans << endl;
}

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

k, n = map(int, input().split())
a = list(map(int, input().split()))

d = [0 for _ in range(n)]
for i in range(n):
    if i != n-1:
        d[i] = a[i+1]-a[i]
    else:
        d[i] = k+a[0]-a[i]
print(k-max(d))


Measured memory_bytes: 26436
/*
ye mera template hai
apna khud likho bc :P
*/

/*
Author : Sarvagya Agarwal
*/

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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int32_t main()
{
    fast;
    int n , a , b ; 
    cin >> n >> a >> b ; 
    int curr = 1 , ans = 0 ; 
    for(int i = 1 ; i <= n ; ++i) {
        int pos ; 
        cin >> pos ; 
        if(i==1) {
            curr = pos ;  
        }
        else {
        ans += min(b , (pos-curr)*a) ; 
        curr = pos ;

    }}
    cout << ans ; 
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s;
    int k;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else{
        cout << s.substr(0,k) << "..." << endl;
    }
}

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

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ll long long int
#define ull unsigned long long int
#define MAX 1000000007
#define MOD 998244353

#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));

ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}

int main(){
    IO
    ll N,A;
    cin>>N>>A;
    ll x[N+1],sum=0;
    for(ll i=1;i<=N;i++) {cin>>x[i];x[i]-=A;}

    map<pll,ll> mp;
    mp[{0,0}]=1;
    for(ll i=1;i<=N;i++){
        for(ll j=-2450;j<=2450;j++){
            mp[{i,j}]=mp[{i-1,j}]+mp[{i-1,j-x[i]}];
        }
    }
    cout<<mp[{N,0}]-1;
    return(0);
}


Measured memory_bytes: 20736
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int N;
    int a[57];

    scanf("%d\n", &N);
    for(int i=1; i<=N; i++)
    {
        scanf("%d ", &a[i]);
    }

    for(int i=1; i<=N; i++)
    {
        if(a[i]!=i)
        {
            for(int k=i+1; k<=N; k++)
            {
                if(a[k]!=k)
                {
                    if((a[i]==k)&&(i==a[k])){ printf("YES\n"); }
                    else{ printf("NO\n"); }
                    return 0;
                }
            }
        }
    }

    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TypicalStairs solver = new TypicalStairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class TypicalStairs {
        public static int MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int[] stairs = new int[n + 1];
            long[] route = new long[n + 1];

            for (int i = 1; i <= m; i++) {
                int step = in.nextInt();
                stairs[step] = 1;
                if (stairs[step - 1] == 1) {
                    out.print(0);
                    return;
                }
            }

            route[0] = 1;
            if (stairs[1] == 0) {
                route[1] = 1;
            }

            if (n <= 1) {
                out.print(route[1]);
                return;
            }

            if (stairs[2] == 0) {
                route[2] = 1;
            }
            for (int i = 1; i <= n - 1; i++) {
                if (stairs[i] == 1) {
                    continue;
                }
                if ((i + 1) <= n && stairs[i + 1] == 0) {
                    route[i + 1] = (route[i] + route[i + 1]) % MOD;
                }
                if ((i + 2) <= n && stairs[i + 2] == 0) {
                    route[i + 2] = (route[i] + route[i + 2]) % MOD;
                }
            }

            out.print(route[n] % MOD);

        }

    }
}



Measured memory_bytes: 58784
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

LL N;
LL dp[2145141];

int main() {
  scanf("%lld", &N);

  if (N == 1) {
    puts("1");
    return 0;
  }

  dp[0] = 1;
  LL sum = dp[0];
  LL ans = (1 + (N-1) * (N-1)) % MOD;
  reps(i, 1, N+1) {
    dp[i] = sum;
    if (i >= 2) dp[i] = (dp[i] + MOD - dp[i-2]) % MOD;
    //if (i > N) dp[i] = (dp[i] + MOD - dp[i-1]) % MOD;
    if (i <= N-2) ans = (ans + dp[i] * (N-1) % MOD * (N-1)) % MOD;
    if (i <= N-2) ans = (ans + dp[i] * (i+1) % MOD);
    sum = (sum + dp[i]) % MOD;
  }

  //rep(i, N+1) {
  //  printf("dp[%d]: %lld\n", i, dp[i]);
  //}

  ans = (ans + dp[N-1] * (N-1) % MOD) % MOD;
  ans = (ans + dp[N]) % MOD;
  printf("%lld\n", ans);
}


Measured memory_bytes: 8448
#include <stdio.h>
int main(void){
    // Your code here!
    int h1,h2,k1,k2,a,b,c,d;
    scanf("%d%d%d%d%d%d%d%d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
    if(h1*a+h2*b+(h1/10)*c+(h2/20)*d>k1*a+k2*b+(k1/10)*c+(k2/20)*d){
        puts("hiroshi");
    }else if(h1*a+h2*b+(h1/10)*c+(h2/20)*d<k1*a+k2*b+(k1/10)*c+(k2/20)*d){
        puts("kenjiro");
    }else{
        puts("even");
    }
}



Measured memory_bytes: 2108
#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>
#include <stack>
using namespace std;

int main()
{
	int N, D;
	cin >> N >> D;
	int X[10][10];
	for (auto i = 0; i < N; ++i)
	{
		for (auto j = 0; j < D; ++j)
		{
			cin >> X[i][j];
		}
	}

	auto count = 0;
	for (auto i = 0; i < N - 1; ++i)
	{
		for (auto j = i + 1; j < N; ++j)
		{
			auto lenSq = 0;
			for (auto k = 0; k < D; ++k)
			{
				lenSq += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}

			for (auto k = 0; k < 128; ++k)
			{
				if (lenSq == k * k)
				{
					++count;
					break;
				}
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
x = int(input())
dp = [0 for i in range(x+1)]
items = [100, 101, 102, 103, 104, 105]
for item in items:
    for i in range(item, x+1):
        if dp[i] < dp[i-item] + item:
            dp[i] = dp[i-item] + item

print(1 if dp[x] == x else 0)
# print(dp)


Measured memory_bytes: 7064
/*
author:Manson
date:7.7.2018
theme:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1005;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int a,b,c;
	a = n/100;
	b = n/10%10;
	c = n%10;
	int temp1 = 100*a+10*a+a;
	if(temp1 >= n){
		cout<<temp1<<endl;
	}
	else{
		cout<<111*(a+1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,aa[202020],dp[202020][3],sum,sum1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>aa[i];
		sum+=aa[i];
	}
	if(n==3)
	{
		cout<<max(aa[1],max(aa[2],aa[3]))<<endl;
		return 0;
	}
	if(n%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			dp[i][0]=-1e16;
			dp[i][1]=-1e16;
		}
		dp[1][0]=aa[1];
		dp[2][1]=aa[2];
		for(int i=3;i<=n;i++)
		{
			dp[i][0]=dp[i-2][0]+aa[i];
			dp[i][1]=max(dp[i-3][0],dp[i-2][1])+aa[i];
		}
		cout<<max(dp[n-1][0],dp[n][1])<<endl;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			dp[i][0]=-1e16;
			dp[i][1]=-1e16;
			dp[i][2]=-1e16;
		}
		dp[1][0]=aa[1];
		dp[2][1]=aa[2];
		dp[3][0]=dp[1][0]+aa[3];
		dp[3][2]=dp[0][0]+aa[3];
		for(int i=4;i<=n;i++)
		{
			dp[i][0]=dp[i-2][0]+aa[i];
			dp[i][1]=max(dp[i-3][0],dp[i-2][1])+aa[i];
			dp[i][2]=max(max(dp[i-4][0],dp[i-3][1]),dp[i-2][2])+aa[i];
		}
		cout<<max(dp[n-2][0],max(dp[n-1][1],dp[n][2]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 9848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m, p;

int main() {
	while (cin >> n >> m >> p&&n + m + p) {
		double x = 0;
		double sum = 0;
		REP(i, n) {
			double y;
			cin >> y;
			sum += y * 100;
			if (i + 1 == m)x = y;
		}
		if (x == 0) {
			cout << 0 << endl;
			continue;
		}
		sum *= (100 - p);
		sum /= 100;
		sum /= x;
		cout << (int)sum << endl;
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
// header {{{
#define all(x) std::begin(x), std::end(x)
#define rall(x) std::rbegin(x), std::rend(x)
#define rep(i, begin, end) for (std::make_signed_t<std::remove_cv_t<decltype(end)>> i = (begin), i##_end = (end); i < i##_end; ++i)
#define repc(i, begin, last) for (std::make_signed_t<std::remove_cv_t<decltype(end)>> i = (begin), i##_last = (last); i <= i##_last; ++i)
#define repr(i, begin, last) for (std::make_signed_t<std::remove_cv_t<decltype(end)>> i = (begin), i##_last = (last); i >= i##_last; --i)
#define let const auto
using i64 = std::int64_t;
using u64 = std::uint64_t;
constexpr std::int32_t INF = 0x3f3f3f3f;
constexpr std::int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class Container, class = typename Container::value_type, std::enable_if_t<!std::is_same_v<Container, std::string>, std::nullptr_t> = nullptr>
std::istream& operator>>(std::istream& is, Container& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <class Container, class = typename Container::value_type, std::enable_if_t<!std::is_same_v<Container, std::string>, std::nullptr_t> = nullptr>
std::ostream& operator<<(std::ostream& os, const Container& v) {
    for (auto it = std::begin(v); it != std::end(v); ++it) os << &" "[it == std::begin(v)] << *it;
    return os;
}

template <class T>
std::istream& operator,(std::istream& is, T& rhs) {
    return is >> rhs;
}

#define var(type, ...) \
    type __VA_ARGS__;  \
    std::cin >> __VA_ARGS__

inline void println() {
    std::cout << '\n';
}
template <class Head, class... Tail>
inline void println(Head&& head, Tail&&... tail) {
    std::cout << head << &" "[!sizeof...(tail)];
    println(std::forward<Tail>(tail)...);
}

template <class T, class U>
inline bool chmin(T& a, const U& b) {
    return b < a && (a = b, true);
}

template <class T, class U>
inline bool chmax(T& a, const U& b) {
    return b > a && (a = b, true);
}
// }}}

using namespace std;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(12);

    var(string, s);
    if (s.back() != 's') {
        s += 's';
    } else {
        s += "es";
    }

    println(s);

    return 0;
}



Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return list(map(int, input().split()))

S = input()
A = set("ATCG")
ans = 0
mode = 0
for i, s in enumerate(S):
    if s in A:
        if mode == 0:
            mode = 1
            start = i
    else:
        if mode == 1:
            ans = max(i - start, ans)
            mode = 0
if mode == 1:
    ans = max(len(S) - start, ans)
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<string>
#include<iostream>

#define FOR(i,m,n) for (int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
//#define DEBUG(a) printf("%d\n", a)
#define DEBUG(a) std::cout << a << std::endl;

using namespace std;

int main()
{
  std::string s;
  std::cin >> s;

  int flag = 0;

  FOR(i,0,3) {
    int c=0;
    FOR(j,i+1,4) {
      if (s[i] == s[j])
        c++;
    }
    if (c == 1)
      flag += 1;
  }
    
  if (flag == 2)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;


  //DEBUG(s[0]);

  return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int N = 800 + 10;
const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {1, 0, -1, 0};
int n, m, k;
char S[N][N];
int d[N][N];

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);

    int sx = -1, sy = -1;
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (S[i][j] == 'S') {
        sx = i;
        sy = j;
        break;
    }

    queue<II> Q; Q.push(II(sx, sy));
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            d[i][j] = -1;
    d[sx][sy] = 0;
    while (Q.size()) {
        int x = Q.front().first;
        int y = Q.front().second;
        Q.pop();
        if (x == 1 || x == n || y == 1 || y == m) {
            puts("1");
            return 0;
        }
        if (d[x][y] >= k) continue;
        for (int t = 0; t < 4; ++t) {
            int u = x + DX[t];
            int v = y + DY[t];
            if (1 <= u && u <= n && 1 <= v && v <= m) {
                if (d[u][v] != -1 || S[u][v] == '#') continue;
                d[u][v] = d[x][y] + 1;
                Q.push(II(u, v));
            }
        }
    }

    int ans = 1e9;
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (d[i][j] != -1) {
        int f = min(min(i - 1, j - 1), min(n - i, m - j));
        ans = min(ans, (f + k - 1) / k + 1);
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>

int main() {

	int n;
	int i;
	int flag,count;
	char c[400];
	int Answer[200],a=0;

	for(;;) {
		scanf("%d",&n);
		if(n==0) break;

		for(i=0;i<3*n;i++)
			scanf("%c",&c[i]);

		flag=0,count=0;
		for(i=1;i<3*n;i+=3) {
			if(c[i+1]=='u') {
				if(flag==0) flag++;
				else if(flag==1) {
					count++;
					flag=0;
				}
				else if(flag==-1) flag++;
			}

			else {
				if(flag==0) flag--;
				else if(flag==-1) {
					count++;
					flag=0;
				}
				else if(flag==1) flag--;
			}
		}
		Answer[a]=count;
		a++;
	}

	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);

	return 0;
}

Measured memory_bytes: 600
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#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 red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

map<string,LL> m;

int main()
{
    NO_TLE
    string s;
    int n;
    LL sum=0;
    cin>>n;
    while(n--)
    {
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(auto it=m.begin();it!=m.end();++it)
    {
        LL t=(it->second);
        sum+=t*(t-1)/2;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;
int main() {
        vector<string>VS{ "Opened by ","Closed by ","Unknown " };
        set<string>SS;
        int N;
        cin >> N;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                SS.insert( S );
        }
        sleep(2);
        cin >> N;
        bool x = 0;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
                        cout << VS[2] << S << endl;
                } else {
                        cout << VS[x] << S << endl;
                        x = 1 - x;
                }
        }
        return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#define ll long long

int main(){
    ll n;
    scanf("%lld", &n);
    ll x2 = 1000000000;
    ll y2 = 0;
    ll x3 = (x2-n%x2)%x2;
    ll y3 = (n+x3)/x2;

    printf("0 0 %lld 1 %lld %lld\n", x2, x3,y3);
    
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> divisors = divisor(m);
  ll smallest = 1000000000000;
  for(int i=0; i<divisors.size(); i++){
    if(divisors[divisors.size()-1-i] < n){
      break;
    }
    smallest = divisors[divisors.size()-1-i];
  }
  cout << m/smallest << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
int s[1100];
int dp[110][11000];
int ans = 0;

int main() {
	cin >> n;
	REP(i, n) {
		cin >> s[i];
	}
	dp[0][0] = 1;
	REP(i, n) {
		REP(j, 11000 - s[i]) {
			if (dp[i][j]) {
				dp[i + 1][j + s[i]] = dp[i][j];
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	REP(j, 10010) {
		if (dp[n][j] && j % 10 != 0)ans = max(ans, j);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3200
def calc_waru(n):
    return n/2
N = int(input())
A = list(map(int, input().split()))
cnt = 0
flag = 0
while True:
    for i in A:
        if i % 2 != 0:
            flag = 1
    if flag == 0:
        A = list(map(calc_waru, A))
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  int ans = 1;
  int cnt = 0;
  
  cin >> a >> b;
  
  while (ans < b) {
    ans -= 1;
    ans += a;
    cnt++;
  }
  
  cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
  string S;
  cin >> S;
  if(S[S.size()-1] != 's') {
    cout << S << 's' << endl;
  }
  else {                                                                                                        
    cout << S << "es" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}






    
void test_case() {


   int n;
   cin>>n;

   set<string> st;

   rep(i,n) {
       string s;
       cin>>s;

       st.insert(s);
   }

   cout<<st.size()<<endl;

    


   

    

}


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

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


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

void solve() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var (A, B) = Read2Longs();
            var P = ReadLongs();

            var countP1 = 0L;
            var countP2 = 0L;
            var countP3 = 0L;
            foreach (var item in P)
            {
                if (item <= A)
                {
                    countP1++;
                }
                else if (item <= B)
                {
                    countP2++;
                }
                else
                {
                    countP3++;
                }
            }

            return Math.Min(countP1, Math.Min(countP2, countP3));
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28056
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int L = 0;
        int nL = 0;
        for(int i=0;i<N;i++){
            if(s[i] == ')'){
                nL++;
                L = Math.Max(L,nL);
            }
            else{
                nL--;
            }
        }
        for(int i=0;i<L;i++){
            sb.Append('(');
        }
        sb.Append(s);
        int R = 0;
        int nR = 0;
        for(int i=N-1;i>=0;i--){
            if(s[i] == '('){
                nR++;
                R = Math.Max(R,nR);
            }
            else{
                nR--;
            }
        }
        for(int i=0;i<R;i++){
            sb.Append(')');
        }
        sb.Append("\n");
    }
}

Measured memory_bytes: 11092
n = int(input())
ab = [[int(i) for i in input().split()] for _ in range(n)]
ab.sort(key=lambda x:x[1])
a, s = 1, 0
for i in ab:
    s += i[0]
    if s > i[1]:
        a = 0
        break
print("Yes") if a == 1 else print("No")

Measured memory_bytes: 41172
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <deque>

using namespace std;
using ulli = unsigned long long int;

int main(void){
	ulli n;
	cin >> n;
	
	vector<ulli> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	
	deque<ulli> b;
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0){
			b.push_back(a[i]);
		}
		else{
			b.push_front(a[i]);
		}
	}
	if(n % 2 == 0){
		for(int i = 0; i < n; ++i){
			cout << b[i];
			if(i != n - 1){
				cout << ' ';
			}
			else{
				cout << endl;
			}
		}
	}else{
		for(int i = n - 1; i >= 0; --i){
			cout << b[i];
			if(i != n - 1){
				cout << ' ';
			}
			else{
				cout << endl;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin>>n;
    string s[n];rep(i,0,n-1)cin>>s[i];
    bool flag=true;
    rep(i,0,n-2){
        if(s[i][s[i].size()-1]!=s[i+1][0])flag=false;
    }
    sort(s,s+n);
    rep(i,0,n-2){
        if(s[i]==s[i+1])flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



int main() {
  int a[3][3];
  bool f[3][3];
  rep(i, 3) {
    rep (j, 3) {
      cin >> a[i][j];
      f[i][j] = false;
    }
  }

  int n;
  cin >> n;

  rep(k, n) {
    int b;
    cin >> b;
    rep(i, 3) {
      rep(j, 3) {
        if (a[i][j] == b) {
          f[i][j] = true;
        }
      }
    }
  }

  if ((f[0][0]&&f[1][0]&&f[2][0])
    || (f[0][1]&&f[1][1]&&f[2][1])
    || (f[0][2]&&f[1][2]&&f[2][2])
    || (f[0][0]&&f[0][1]&&f[0][2])
    || (f[1][0]&&f[1][1]&&f[1][2])
    || (f[2][0]&&f[2][1]&&f[2][2])
    || (f[0][0]&&f[1][1]&&f[2][2])
    || (f[0][2]&&f[1][1]&&f[2][0])
  ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

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

	long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] t = new int[n];
		int[] p = new int[n];
		int[] x = new int[s];
		for (int i = 0; i < s; ++i) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; ++i) {
			t[i] = sc.nextInt();
			p[i] = sc.nextInt();
			--p[i];
		}
		int[] w = new int[n];
		for (int i = 0; i < n; ++i) {
			w[i] = t[i] - x[p[i]];
		}
		Arrays.sort(w);

		solve(n, m, w);
	}

	void solve(int n, int m, int[] w) {
		long ans = 0;
		for (long v : w) {
			ans -= v;
		}
		long[][] f = new long[n + 1][m + 1];
		for (int i = 0; i < f.length; ++i) {
			for (int j = 0; j < f[i].length; ++j) {
				f[i][j] = Integer.MAX_VALUE / 16;
			}
		}
		for (int i = 1; i < f.length; ++i) {
			f[i][1] = w[i - 1] * i;
		}

		for (int j = 2; j <= m; ++j) {
			// j is fixed.
			// Attention: h[i][k]:=f[k][j-1]+w[i-1]*(i-k) is of Monge.
			// min(h[i][]) can be enumerated in O(n*log(n))
			// f[i][j]=min(h[i][])
			long[] v = calc(f, w, j);
			for (int i = 1; i <= n; ++i) {
				// for (int k = 1; k <= i - 1; ++k) {
				// f[i][j] = Math.min(f[i][j], h(f, w, i, j, k));
				// }
				f[i][j] = v[i];
			}
		}

		long min = Integer.MAX_VALUE / 16;
		for (int j = 1; j <= m; ++j) {
			min = Math.min(min, f[n][j]);
		}
		ans += min;
		System.out.println(ans);
	}

	long[] calc(long[][] f, int[] w, int j) {
		int n = f.length - 1;
		int m = f[0].length - 1;
		long[] ret = new long[n + 1];
		Arrays.fill(ret, Integer.MAX_VALUE / 16);
		rec(ret, 1, n, 2, n + 1, f, w, j);
		return ret;
	}

	// [low,high]
	// [left,right)
	long rec(long[] ret, int low, int high, int left, int right, long[][] f, int[] w, int j) {
		int mid = (left + right) / 2;// the value of the variable i
		long v = Long.MAX_VALUE / 16;
		int arg = -1;
		for (int k = Math.max(0, low); k <= Math.min(mid - 1, high); ++k) {
			v = Math.min(v, h(f, w, mid, j, k));
			if (v == h(f, w, mid, j, k))
				arg = k;
		}
		if (right - left > 1) {
			rec(ret, low, arg, left, mid, f, w, j);
			rec(ret, arg, high, mid, right, f, w, j);
		}
		ret[mid] = v;
		return v;
	}

	long h(long[][] f, int[] w, int i, int j, int k) {
		return f[k][j - 1] + w[i - 1] * (i - k);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

long long N, A[7], B[7], dp[13][10][1 << 13];

void init() {
	for (int i = 0; i < 13; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < (1 << 13); k++) dp[i][j][k] = -1;
		}
	}
}
long long solve(int pos, int mae, int mask) {
	if (mask == 0) return 0;
	if (dp[pos][mae][mask] >= 0) return dp[pos][mae][mask];

	int bit[13]; for (int j = 0; j <= N * 2; j++) bit[j] = (mask / (1 << j)) % 2;

	long long ans = 0;
	if (mask >= (1LL << (2 * N - 1)) && A[N - 1] <= mae && mae <= B[N - 1]) ans++;
	else if (mask >= (1LL << (2 * N))) ans++;

	for (int i = 0; i < 10; i++) {
		int bit2[13]; for (int j = 0; j <= N * 2; j++) bit2[j] = 0;

		for (int j = 0; j <= N * 2; j++) {
			if (bit[j] == 0) continue;
			int V1 = ((j - 1) >> 1), V2 = 0; if (j >= 1) V2 = ((j - 1) & 1) + 1; else V1 = 0;

			if (V2 == 0) {
				if (i >= 1 && i <= B[V1]) bit2[j + 1] = 1;
			}
			else if (V2 == 1) {
				if (A[V1] <= mae && i <= B[V1 + 1] && i >= 1) bit2[j + 2] = 1;
				if (A[V1] <= mae * 10 + i && mae * 10 + i <= B[V1]) bit2[j + 1] = 1;
			}
			else {
				if (i >= 1 && i <= B[V1 + 1]) bit2[j + 1] = 1;
			}
		}
		int F = 0; for (int j = 0; j <= N * 2; j++) F += (bit2[j] << j);

		ans += solve(pos + 1, i, F);
	}
	dp[pos][mae][mask] = ans;
	return ans;
}

int main() {
	while (true) {
		init();
		cin >> N; if (N == 0) break;
		for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

		long long ret = solve(0, 0, 1);
		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 11408
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;

typedef complex<double> P;

double cross(const P &a, const P &b){
	return a.real() * b.imag() - a.imag() * b.real();
}

vector<P> intersect(const P &p1, const P &p2, double r){
	double d = abs(p2 - p1);
	double phi = arg(p2 - p1);
	double theta = acos(0.5 * d / r);
	
	vector<P> ret(2);

	ret[0] = p1 + polar(r, phi + theta);
	ret[1] = p1 + polar(r, phi - theta);
	return ret;
}

bool contains(const vector<P> &plg, const P &pt){
	int cnt = 0;
	double y = imag(pt);

	for(int i = 0; i < plg.size(); ++i){
		int j = (i + 1 == plg.size() ? 0: i + 1);

		double dyi = imag(plg[i]) - y;
		double dyj = y - imag(plg[j]);
		double tx = (dyi * real(plg[j]) + dyj * real(plg[i])) / (dyi + dyj);

		if(imag(plg[i]) >= y && imag(plg[j]) < y){
			if( tx < real(pt) ) ++cnt;
		}
		else if(imag(plg[i]) < y && imag(plg[j]) >= y){
			if( tx < real(pt) ) ++cnt;
		}
	}
	
	return (cnt % 2 != 0);
}

P centroid(const vector<P> &p){
	double sum = 0.0;
	P c;
	int n = p.size();

	for(int i = 0; i < n; ++i){
		int next = (i + 1) % n;

		double crs = cross(p[i], p[next]);
		c += (p[i] + p[next]) * crs;
		sum += crs;
	}
	
	return c / (3.0 * sum);
}

int main(){
	double pi = acos(-1.0);

	vector<P> pt;
	pt.reserve(102000);
	
	string type;
	double x, y, r;

	while( cin >> type, type[0] != 'e' ){
		pt.clear();
		
		cin >> x >> y;
		pt.push_back( P(x, y) );

		while( cin >> type, type[0] != 'c' ){
			if( type[0] == 'l' ){
				cin >> x >> y;
				pt.push_back( P(x, y) );
			}
			else{
				cin >> x >> y >> r;
				double absr = abs(r);
				
				P p(x, y);
				vector<P> intr = intersect(pt.back(), p, absr);

				P c;
				double crs = cross(p - pt.back(), intr[0] - pt.back());
				if( (r < 0) == (crs > 0) ){
					c = intr[0];
				}
				else{
					c = intr[1];
				}

				double arg1 = arg(pt.back() - c);
				double arg2 = arg(p - c);
				if( arg1 > arg2 + pi ){	arg2 += 2.0 * pi;	}
				else if( arg2 > arg1 + pi ){	arg1 += 2.0 * pi;	}

				double darg = arg2 - arg1;
				for(int j = 1; j <= 1000; ++j){
					pt.push_back( c + polar(absr, arg1 + j * 0.001 * darg ) );
				}
			}
		}
		
		P cent = centroid(pt);
		bool cont = contains(pt, cent);
		
		printf("%f %f %c\n", cent.real(), cent.imag(), cont ? '+' : '-' );
	}
}

Measured memory_bytes: 1536
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas


def is_prime(num):
    for i in range(2, int(sqrt(num))):
        if num % i == 0:
            return False
    return True

X = intinput()

if X == 2:
    print(X)
    exit()

if X % 2 == 0:
    X += 1

while not is_prime(X):
    X += 2

print(X)


Measured memory_bytes: 5276
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	int now=0,mx=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='I'){
			now++;
			mx=max(mx,now);
		}
		if(s[i]=='D'){
			now--;
		}
	}
	cout << mx << endl;
	return 0;
	
}


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

const int N = 100010;
char s[N];
int n, ans[N], to[N];
bool vis[N];
int opp[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i) {
		if(s[i] == 'R' && s[i + 1] == 'L') vis[i] = vis[i + 1] = 1, opp[i] = i + 1, opp[i + 1] = i;
	}
	int now;
	for(int i = 1; i <= n; ++i) {
		if(vis[i] == 1) now = i;
		if(s[i] == 'L') to[i] = now;
	}
	for(int i = n; i; --i) {
		if(vis[i] == 1) now = i;
		if(s[i] == 'R') to[i] = now;
	}
	for(int i = 1; i <= n; ++i) {
		if(s[i] == 'L') {
			if(abs(to[i] - i) & 1) ans[to[i] - 1]++;
			else ans[to[i]]++;
		} else {
			if(abs(to[i] - i) & 1) ans[to[i] + 1]++;
			else ans[to[i]]++;
		}
	}
	for(int i = 1; i <= n; ++i) printf("%d ", ans[i]);
}

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

using namespace std;
 
int main() {
    int group[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int a, b;
    cin >> a >> b;
 
 
    if (group[a] == group[b]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int op(int a, int b) { return max(a, b);}
int e() {return 0;}

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

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    segtree <int, op, e> seg(300010);
    int ans=0;
    rep (i, n) {
        int l = max(a[i] - k, 0);
        int r = min(a[i] + k, 300000);
        int tmp = seg.prod(l, r+1) + 1;
        ans = max(ans, tmp);
        seg.set(a[i], tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9796
while True:
    m_test_point, f_test_point, r_test_point = map(int, input().split())
    if m_test_point == f_test_point == r_test_point == -1:
        break
    m_f_total = m_test_point + f_test_point
    if m_test_point == -1 or f_test_point == -1 or m_f_total < 30:
        print("F")
    elif m_f_total >= 80:
        print("A")
    elif 65 <= m_f_total < 80:
        print("B")
    elif 50 <= m_f_total < 65:
        print("C")
    elif 30 <= m_f_total < 50 and r_test_point >= 50:
        print("C")
    elif 30 <= m_f_total < 50:
        print("D")


Measured memory_bytes: 5596