akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
vector<int> G[maxn];
int col[maxn];
void dfs1(int u,int color) {
	col[u] = color;
	for(int v : G[u])
		if(col[v] == 0)
			dfs1(v,color);
}
int ans[maxn];
void dfs2(int u,vector<int> &idxs) {
	ans[u] = -1;	// visited
	idxs.emplace_back(u);
	for(int v : G[u])
		if(ans[v] == 0)
			dfs2(v,idxs);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k,l;
	cin >> n >> k >> l;
	for(int i=1,u,v;i<=k;i++) {
		cin >> u >> v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	int tmp = 1;
	for(int i=1;i<=n;i++)
		if(col[i] == 0)
			dfs1(i,tmp) , tmp++;
	for(int i=1;i<=n;i++)
		G[i].clear();
	for(int i=1,u,v;i<=l;i++) {
		cin >> u >> v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	for(int i=1;i<=n;i++)
		if(ans[i] == 0) {
			vector<int> idxs;
			dfs2(i,idxs);
			
			sort(idxs.begin(),idxs.end(),[=](int a,int b)->bool
				{return col[a] < col[b];});
			for(int j=0;j<(int)idxs.size();) {
				int r = upper_bound(idxs.begin(),idxs.end(),idxs[j],[=](int a,int b)->bool
					{return col[a] < col[b];})-idxs.begin()-1;
				int num = r - j + 1;
				for(;j<=r;j++)
					ans[idxs[j]] = num;
			}
		}
	for(int i=1;i<=n;i++) {
		if(i != 1)	cout << " ";
		cout << ans[i];
	}	
	cout << '\n';
	return 0;
}


Measured memory_bytes: 12036
N,A,B,C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = float('inf')
for i in range(1<<N):
    for j in range(1<<N):
        a,b,c = [],[],[]
        cost = 0
        for keta in range(N):
            bit_i = i&(1<<keta)
            bit_j = j&(1<<keta)
            if bit_i==0 and bit_j==0:
                a.append(keta)
            elif bit_i==0 and bit_j>0:
                b.append(keta)
            elif bit_i>0 and bit_j==0:
                c.append(keta)
            else:
                pass
        if a==[] or b==[] or c==[]:
            continue
        cost += 10*(len(a)+len(b)+len(c)-3)
        for l,val in zip([a,b,c],
                         [A,B,C]):
            s = sum([L[li] for li in l])
            cost += abs(s-val)
        ans = min(ans, cost)

print(ans)
                

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

long long N, X, S, A[1 << 18], L[1 << 18], R[1 << 18];
vector<pair<long long, int>> E;

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> L[i] >> R[i];
		S += A[i] * L[i];
		E.push_back(make_pair(L[i] * A[i] + R[i] * (X - A[i]), i));
	}
	sort(E.begin(), E.end());
	reverse(E.begin(), E.end());

	long long shou = 0;
	for (int i = 0; i < E.size(); i++) {
		if (E[i].first <= S) { shou++; S -= E[i].first; }
		else break;
	}

	long long minx = X;
	for (int i = shou; i < E.size(); i++) {
		int id = E[i].second;
		if (S < A[id] * L[id]) minx = min(minx, (S + L[id] - 1LL) / L[id]);
		else {
			long long V = S - A[id] * L[id];
			minx = min(minx, A[id] + (V + R[id] - 1LL) / R[id]);
		}
	}

	if (shou < (int)E.size()) {
		S -= E[shou].first;
		for (int i = 0; i < shou; i++) {
			long long T = S + E[i].first;

			int id = E[i].second;
			if (T < A[id] * L[id]) minx = min(minx, (T + L[id] - 1LL) / L[id]);
			else {
				long long V = T - A[id] * L[id];
				minx = min(minx, A[id] + (V + R[id] - 1LL) / R[id]);
			}
		}
	}
	else minx = 0;

	cout << 1LL * shou * X + minx << endl;
	return 0;
}

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

const int N = (int)1e5+5;
const int INF = (int)1e9+5;
int n, h[N], dp[N];

int solve(int cur) {
	if (cur == n) return 0;
	if (dp[cur] != -1) return dp[cur];
	int ret = INF;
	if (cur+1 <= n) ret = min(ret, solve(cur+1)+abs(h[cur]-h[cur+1]));
	if (cur+2 <= n) ret = min(ret, solve(cur+2)+abs(h[cur]-h[cur+2]));
	return dp[cur] = ret;
}

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

	memset(dp, -1, sizeof dp);
	printf("%d\n", solve(1));

	return 0;
}

Measured memory_bytes: 5760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

class B1 {
public:
void solve(std::istream& cin, std::ostream& cout) {
//    ll a;
//    ll i=0;
//    ll ans = 0;
//    //string ans = "";
//    cin >> a;
//    ll mon = 100;
//    while(mon < a){
//        i++;
//        mon *= 1.01;
////        if(mon >= a){
////            ans = i;
////            break;
////        }
//    }
//    ans = i;
//    cout << ans << endl;
    long long X;
    cin >> X;
    long long P = 100, step = 0;
    while(P < X){
        P += P / 100;
        step++;
    }
     cout << step << endl;
}
};


int main() {
	B1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N, K;
  string S;
  cin >> N >> S >> K;
  char r = S[K-1];
  for(char c:S)
  {
    if(c !=r)
      cout << '*';
    else
      cout << c;
  }
  cout << endl;
  return 0;
}


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

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n,i;
    cin>>n;
     int a[n+1],x,ans=0;
     for(i=0;i<n;i++)
       cin>>a[i];
     for(i=0;i<n;i++)
      if(i+1==a[i])
      {   ans++;
          swap(a[i],a[i+1]);    
      }
      cout<<ans;
      
      
    
	return 0;
}

Measured memory_bytes: 640
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<pair<int,int>> G[1000000];
vector<int> color(1000000,0);

void dfs(int startpoint, int frompoint, int fromcolor, int maxjisuu){

    for(pair<int,int> i : G[startpoint]){
        if(i.first == frompoint) continue;
        color[i.second] = (fromcolor+=1) % maxjisuu;
        dfs(i.first, startpoint, color[i.second], maxjisuu);

    }



}

int main(void){

    int N; cin>>N;

    for (int i = 1; i <= N-1; ++i) {
        int a,b; cin>>a>>b;
        G[a].push_back(make_pair(b,i));
        G[b].push_back(make_pair(a,i));
    }
    int maxjisuu = 0;
    for (int i = 0; i <= N; ++i) {
        maxjisuu = max(maxjisuu, (int)G[i].size());
    }
    cout<<maxjisuu<<endl;

    dfs(1,0,0,maxjisuu);

    for (int i = 1; i <= N-1; ++i) {
        cout<<color[i]+1<<endl;
    }

}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	else if (b == c) {
		cout << a << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, h, n, w, q, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli a(n), d(100010, 0);
  rep(i, 0, n)
  {
    cin >> a[i];
    ans += a[i];
    d[a[i]] += 1;
  }
  cin >> q;
  rep(i, 0, q)
  {
    cin >> b >> c;
    count = d[b];
    // cout << "count: " << count << endl;
    d[b] = 0;
    d[c] += count;
    ans -= count * b;
    ans += c * count;
    cout << ans << endl;
  }
}

Measured memory_bytes: 4780
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
  double r;
  double pi = 3.141592653589;

  cin >> r;
  double area = pi * r * r;
  double circle = 2.0 * pi * r;
  printf("%.5f %.5f\n", area, circle);

  return 0;
}



Measured memory_bytes: 3140
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}
int main(){
    int q,M,i;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

long long gcd(long long a, long long b){
    if(a < b) swap(a, b);
    if(a % b == 0) {
        return b;
    }
    else{
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b){
    return (max(a, b) / gcd(a, b)) * min(a, b);
}
 
void solve() {
    int N;
    cin >> N;
    long long T[N];
    REP(i, N) cin >> T[i];
    long long ans = T[0];
    for(int i = 1; i < N; i++){
        ans = lcm(ans, T[i]);
    }
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys

def solve(a,b):

	count=0
	for g in range(len(a)):
		if(a[g]!=b[g]):
			count+=1
	return count

S=sys.stdin.readline().strip()
T=sys.stdin.readline().strip()

l=len(T)

ans=100000

for a in range(len(S)-len(T)+1):
	ans=min(ans,solve(S[a:a+l],T))

print(ans)

Measured memory_bytes: 9136
s=list(input())
s=s[::-1]
start=0
def find(s,start):
    if len(s)-start>=5 and (s[start:start+5]==list("maerd") or s[start:start+5]==list("esare")):
        start=start+5
        return(start,0)#左がstart,右がまだ処理続行
    elif len(s)-start>=6 and s[start:start+6]==list("resare"):
        start=start+6
        return(start,0)
    elif len(s)-start>=7 and s[start:start+7]==list("remaerd"):
        start=start+7
        return(start,0)
    elif len(s)-start==0:
        return(start,1)#1はぴったり終了
    else:
        return(start,2)#2は満たさないで終了
shori=0
while shori==0:
    (start,shori)=find(s,start)
if shori==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 4776
class Tree:
    root = None

    def insert(self, node):
        y = None
        x = self.root
        while x:
            y = x
            x = x.left if node.key < x.key else x.right

        if not y:
            self.root = node
        elif node.key < y.key:
            y.left = node
            node.parent = y
        else:
            y.right = node
            node.parent = y

    def print(self):
        print(' ', end='')
        print(*self.root.print_in())
        print(' ', end='')
        print(*self.root.print_pre())

    def find(self, node):
        y = None
        x = self.root
        while x:
            y = x
            if node.key == x.key:
              break
            elif node.key < x.key:
              x = x.left
            else:
              x = x.right
            
        
        if not y:
            print("no")
        elif node.key == y.key:
            return y
        else:
            print("no")

    def delete1(self, node):
        y = node.parent
        if y.key < node.key:
          y.right = None
        elif y.key > node.key:
          y.left = None
        node.parent = None

    def delete2(self, node):
        y = node.parent
        if y.key < node.key:
          y.right = node.right
        else:
          y.left = node.right
        node.right.parent = y

    def delete3(self, node):
        y = node.parent
        if y.key < node.key:
          y.right = node.left
        else:
          y.left = node.left
        node.left.parent = y
    
    def delete4(self, node):
        y = node.right
        x = y
        while x.left:
          x = x.left

        node.key = x.key
        if y == x:
          node.right = None
          
        if not x.left and not x.right:
          self.delete1(x)
        elif not x.left and x.right:
          self.delete2(x)
        else:
          self.delete3(x)

    def delete(self, node):
        y = self.find(node)
        if y:
          if not y.left and not y.right:
             self.delete1(y)

          elif not y.left and y.right:
             self.delete2(y)
        
          elif y.left and not y.right:
             self.delete3(y)

          else:
             self.delete4(y)

class Node:
    def __init__(self, key):
        self.left = None
        self.right = None
        self.key = key
        self.parent = None

    def print_pre(self):
        yield self.key
        if self.left:
            for k in self.left.print_pre(): yield k
        if self.right:
            for k in self.right.print_pre(): yield k

    def print_in(self):
        if self.left:
            for k in self.left.print_in(): yield k
        yield self.key
        if self.right:
            for k in self.right.print_in(): yield k


tree = Tree()
m = int(input())

while m:
    l = input().split()
    if len(l) == 2 and l[0] == "insert":
       tree.insert(Node(int(l[1])))
    elif len(l) == 2 and l[0] == "find":
       y = tree.find(Node(int(l[1])))
       if y:
          print("yes")
    elif len(l) == 2 and l[0] == "delete":
       tree.delete(Node(int(l[1])))
    else:
       tree.print()
    m -= 1


Measured memory_bytes: 91232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }


int main() {


	
	int A,B;

	scanf("%d %d", &A,&B);
	
	/*
	
	vector<int> A;
	for (int i = 0;i<N;i++) {
		int tmp;
		scanf("%d",&tmp);
		A.push_back(tmp);
	}
	
	*/


	if (B < A) {

		printf("%d", A - 1);

	}
	else {
		printf("%d", A);
	}

	return 0;
}


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

int main(){
    int N, A;
    A = 0;
    cin >> N;
    vector<int> D1(N),D2(N);
    
    for(int i = 0; i < N; i++){
        cin >> D1.at(i);
        cin >> D2.at(i);
    }
    for(int i = 0; i < N - 2; i++){
        if(D1.at(i) == D2.at(i) && D1.at(i + 1) == D2.at(i + 1)
           && D1.at(i + 2) == D2.at(i + 2)){
            A = 1;
        }
    }
    if(A == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String ans="No";
String s=sc.next();
String t=sc.next();
t+=t;
  if(t.contains(s)){ans="Yes";}else{ans="No";}
System.out.println(ans);
}}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k;
    cin>>n>>k;
    int ans = 0;
    string s;
    cin>>s;
    int cnt = 1;
    rep(i,n-1){
        if(s[i]==s[i+1])++ans;
        else ++cnt;
    }
    while(cnt>=3&&k>0){
        ans += 2;
        cnt -= 2;
        --k;
    }
    if(cnt>=2&&k>0)++ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(int(1e6))

a, b, c = list(map(int, input().split()))

ans = 0
if a < b:
  ans = a
  if b < c:
    ans += b
  else:
    ans += c
else:
  ans = b
  if a < c:
    ans += a
  else:
    ans += c

print(ans)


Measured memory_bytes: 2940
#include<cmath>
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const long double EPS=1e-9;

const int N_MAX=20;
bool Gauss_Jordan(int n,const long double A[N_MAX][N_MAX],const long double *b,long double *x){
	static long double B[N_MAX][N_MAX+1];
	rep(i,n){
		rep(j,n) B[i][j]=A[i][j];
		B[i][n]=b[i];
	}

	rep(i,n){
		int piv=i;
		for(int j=i;j<n;j++) if(abs(B[j][i])>abs(B[piv][i])) piv=j;
		rep(j,n+1) swap(B[i][j],B[piv][j]);

		if(abs(B[i][i])<EPS) return false;

		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		rep(j,n) if(i!=j) for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
	}

	rep(i,n) x[i]=B[i][n];
	return true;
}

int main(){
	for(int a,m,b,n;scanf("%d%d%d%d",&a,&m,&b,&n),a;){
		long double coe[21][20][20]={}; // coe[k][i][j] := (^mãa+^nãb)^k Ì ^mã(a^i)*^nã(b^j) ÌW
		coe[0][0][0]=1;
		rep(k,m*n){
			rep(i,m) rep(j,n) {
				if(i<m-1) coe[k+1][i+1][j]+=coe[k][i][j];
				else      coe[k+1][0][j]+=a*coe[k][i][j];
				if(j<n-1) coe[k+1][i][j+1]+=coe[k][i][j];
				else      coe[k+1][i][0]+=b*coe[k][i][j];
			}
		}

		long double A[20][20],x[20],b[20];
		rep(i,m) rep(j,n) {
			b[i*n+j]=-coe[m*n][i][j];
			rep(k,m*n) A[i*n+j][k]=coe[k][i][j];
		}
		Gauss_Jordan(m*n,A,b,x);

		printf("1 ");
		rep(k,m*n) printf("%.0Lf%c",x[m*n-k-1]+EPS,k<m*n-1?' ':'\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans =0;
    ll a[20],b[20];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    ll tmp;
    rep(i,n){
        tmp = a[i]-b[i];
        if(tmp>0)ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    cout<<s2<<s1;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n=scanner.nextInt(),last=0,ans=0;
        for(int i=0,j;i<n;i++,last=j)if(last>=(j=scanner.nextInt()))ans+=last-j;
        System.out.println(last+ans);
    }
}

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

using namespace std;

int main(){
  int N;
  long long int O =1;
  cin >> N;
  unsigned long int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]==0){
      cout << 0;
      exit(0);
    }
  }
  
  
  for(int i=0;i<N;i++){
    if(log10(O)+log10(A[i])>18 || O*A[i]>1000000000000000000){
      cout << -1;
      exit(0);
    }
    O=O*A[i];
  }

  cout << O;
  return 0;
}


Measured memory_bytes: 4684
#include <iostream>

using namespace std;

int pow(int n, int p) {
	if (p < 0) {
		return 0;
	}
	if (p == 0) {
		return 1;
	}
	int intermed = pow(n, p/2);

	if (p % 2 == 0) {
		return intermed * intermed;
	}
	return intermed * intermed * n;
}

int GetLength(int n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}

int GetRepeatedDigit(int digit_to_repeat, int repetion_time) {
	int n = 0;

	while (repetion_time > 0) {
		n += digit_to_repeat * pow(10, repetion_time - 1);
		repetion_time--;
	}
	return n;
}

int GetNextNumber(int n) {
	int length = GetLength(n);

	int most_significant_digit = n / pow(10, length - 1);

	int first = GetRepeatedDigit(most_significant_digit, length);
	int second; 

	if (most_significant_digit != 9) {
		second = GetRepeatedDigit(most_significant_digit + 1, length);
	} else {
		second = GetRepeatedDigit(1, length + 1);
	}

	if (first >= n) {
		return first;
	} else {
		return second;
	}
}

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

	cout << GetNextNumber(n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char s[50], t[50];
    cin >> s >> t;
    int pos = -1;
    for(int i = strlen(s) - 1; i >= 0; i--) {
        int f = 1;
        if (strlen(s) < strlen(t)) {
            break;
        }
        if (i + strlen(t) - 1 > strlen(s) - 1) {
            continue;
        }
        for (int j = 0; j < strlen(t); j++) {
            if (s[i + j] != '?' && s[i + j] != t[j]) {
                f = 0;
                break;
            }
        }
        if (f) {
            pos = i;
            break;
        }
    }
    if (pos != -1) {
        imfor(i, strlen(s)) {
            if (pos <= i && i <= pos + strlen(t) - 1) {
                cout << t[i - pos];
            }
            else if (s[i] == '?') {
                cout << "a";
            }
            else {
                cout << s[i];
            }
        }
        cout << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }
}

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

using namespace std;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double am = m / 60.0 * (2.0 * M_PI);
    double ah = (h / 12.0 + (m / 60.0 / 12.0)) * (2.0 * M_PI);
    double angle = (am > ah) ? am - ah : ah - am;
    double ans = sqrt(a*a + b*b - 2.0 * a * b * cos(angle));
    printf("%.20lf", ans);
    return 0;
}

Measured memory_bytes: 4188
#include<iostream>
using namespace std;
string solve(){
	int N,H,H2;
	cin>>N;
	cin>>H;
	for(int i=0;i<N-1;i++){
		cin>>H2;
		if(H2<H){
			return "No";
		}
		if(H2>H){
			H=H2-1;
		}else{
			H=H2;
		}
	}
	return "Yes";
}
int main(){
	string ans=solve();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))
i = 0
while i < n and x[i] < 0:
    i += 1
jl = i - 1
cl = []
cr = []
for l in range(k):
    if jl - l < 0:break
    cl.append(-x[jl - l])
for l in range(k):
    if i + l >= n:break
    cr.append(x[i + l])
la = 10**18
lb = 10**18
for l in range(len(cl)):
    c = k - l - 2
    if c >= len(cr):continue
    if c < 0:
        la = min(la, cl[l])
    else:
        la = min(la, cl[l] + cr[c] * 2)
for l in range(len(cr)):
    c = k - l - 2
    if c >= len(cl):continue
    if c < 0:
        lb = min(lb, cr[l])
    else:
        lb = min(lb, cr[l] + cl[c] * 2)
print(min(la, lb))

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

int main(){
    int S , h , m , s ;
    cin >> S;
    h = S / 3600;
    S = S - h * 3600;
    m = S / 60;
    S = S - m * 60;
    s = S;
    cout << h << ":" << m << ":" << s << endl;


    return 0;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main()
{
    long long a,b,c,k=0;
    cin>>a>>b>>c;
    if(a==0)k++;
    if(a%c==0&&a!=0)a--;
    k+=(b/c)-(a/c);
    cout<<k;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long x,y,z,i,j,k,a,b,c,n;
    cin>>n;
    if (n%2==0)
    {
    	cout<<-1<<endl;
    	return 0;
	}
	if (n%5==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	if (n==1 || n==7 )
	{
		cout<<1<<endl;
		return 0;
	}
	arr[0]=7;
	for (i=1;i<=9;i++)
	{
		arr[i]=arr[i-1]*10+7;
	}
	x=n;
		for (i=0;i<=8;i++)
		{
			if (arr[i]>=x)
			{
				y=arr[i];
				break;
			}
		}
		x=n;
		z=i+1;
		y=(y%x)*10+7;
		if (y==7)
		{
			cout<<z<<endl;
			return 0;
		}
	while (1)
	{
		y=(y%x)*10;
		if (y==0)
		{
			z++;
			break;
		}
		y=y+7;
		z++;
	}
	cout<<z<<endl;
}

Measured memory_bytes: 3648
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string a;
    cin >> a;
    int res = 0;
    for (int c : a) {
        res -= (c == 'p');
    }
    res += (int) a.size() / 2;
    cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	string s;	cin >> s;
	ll n = s.size();
	vector<ll> cnt(26);
	rep(i, n)	cnt[s[i] - 'a']++;
	ll ret = 1 + n*(n + 1) / 2;
	rep(i, 26)	ret -= cnt[i] * (cnt[i] + 1) / 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 1e5+5;

int p[N];

int main()
{	
	int n,x;
	ll ans = 0;
	scanf("%d",&n);
	memset(p,0,sizeof(p));
	for(int i = 1;i <= n;++i){
		scanf("%d",&x);
		ans += x;
		p[x]++;
	}
	
	int q,u,v;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&u,&v);
		if(!p[u]) printf("%lld\n",ans);
		else{
			ans -= (ll)p[u]*(ll)u;
			ans += (ll)p[u]*(ll)v;
			p[v] += p[u];
			p[u] = 0;
			printf("%lld\n",ans);
		}
	}
	return 0;
} 

Measured memory_bytes: 4196
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;
    int64_t sa = A-B;
    if(K%2) sa *= -1;
    cout << sa << endl;
}   

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;

class UnionFind {
private:
    vector<int> p, rank;
    int N;
    int findSet2(int i, bool* A){A[i] = 1;return (p[i] == i) ? i : (p[i] = findSet2(p[i], A));}
public:
    UnionFind(int N) {
        rank.assign(N, 0);
        p.assign(N, 0);
        for (int i = 0; i < N; i++) p[i] = i;
        this->N = N;
    }

    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }

    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

    void unionSet(int i, int j) {
        if (!isSameSet(i, j)) {
// if from different set
            int x = findSet(i), y = findSet(j);
            if (rank[x] > rank[y]) p[y] = x;
// rank keeps the tree short
            else {
                p[x] = y;
                if (rank[x] == rank[y]) rank[y]++;
            }
        }
    }


    int numDisjointSets(){
        set<int> s;
        bool* visited = new bool[this->N];
        memset(visited, 0, sizeof(bool)*this->N);
        for (int i = 0; i < N; ++i) {
            if(!visited[i])s.insert(findSet2(i, visited));
        }
        return s.size();
    }

    int maxElements(){
        int mx = 0;
        map<int, int> m;
        for (int i = 0; i < N; ++i) {
            m[findSet(i)] ++;
        }
        set<pair<int, int>> s;
        for(auto p : m){
            s.insert({p.second, p.first});
        }
        return s.rbegin()->first ;
    }


};

vector<int> v;
void _() {
    int a, b;
    cin >> a >>b;
    cout << !!(a%b);

}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    rep(i,0,S.size()-1){
        if(S[i] == S[i+1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    rep(i,0,S.size()-2){
        if(S[i] == S[i+2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_LOOP = 100000;
int a, b, c, x, y;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    int ans = INF;
    cin >> a >> b >> c >> x >> y;
    cout << min({ a * x + b * y, c * 2 * x + b * max(0, y - x), a * max(0, x - y) + c * 2 * y}) << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

int main() {
	long long int L, R;
	cin >> L >> R;
	
    int x1, y1, x2, y2;
	x1 = L % 2019;
	x2 = L / 2019;
	y1 = R % 2019;
	y2 = R / 2019;
	int ans = 2019;
	if (x2 == y2) {
		for (int i = x1; i < y1; i++) {
			for (int j = x1 + 1; j < y1 + 1; j++) {
				if (ans > (i * j) % 2019) {
					ans = (i * j) % 2019;
				}
			}
		}
		cout << ans << endl;
	}
	else {
        cout << 0 << endl;
	}	
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  priority_queue<int, vector<int>, greater<int>> que;
  rep(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }
  if(mp.size() <= k){
    cout << 0 << endl;
    return 0;
  }
  for(auto i: mp){
    que.push(i.second);
  }
  int ans = 0;
  rep(i, mp.size() - k){
    ans += que.top(); que.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 10748
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

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

    int ans = INT_MAX;
    for (int i=0; i<1<<n; i++) {
        int cnt = 0;
        vector<int> at(m,0);
        for (int j=0; j<n; j++) {
            if (i>>j&1) {
                cnt += c[j];
                for (int k=0; k<m; k++) {
                    at[k] += a[j][k];
                }
            }
        }
        if (all_of(at.begin(), at.end(), [&](const int& a){return a>=x;})) {
            ans = min(ans, cnt);
        }
    }

    if (ans == INT_MAX) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
bool kaibun(string s){
    int n = s.length();
    rep(i,n){
        if(s[i]!=s[n-1-i]){
            return false;
        }
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int two = (n-1)/2;
    int three = (n+3)/2;
    string t="";
    string u="";
    rep(i,two){
        t += s[i];
    }
    for(int i=three-1;i<n;i++){
        u += s[i];
    }
    if(kaibun(s)&&kaibun(t)&&kaibun(u)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#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 a, b, c;
//	cin >> a >> b >> c;
//	vector<int> a(n);
//	int max_index=0;
//	int max = 0;
//	int temp_max = 0;
//	rep(i, n) {
//		cin >> a[i];
//		
//		max += a[i];
//		if (i>=k-1) {
//			if (max > temp_max) {
//				max_index = i - k + 1;
//				temp_max = max;
//			}
//			max -= a[i - k + 1];
//		}
//	}
//	//sort(a.rbegin(), a.rend());
//	float sum = 0;
//	rep(i, k) {
//		sum += float(a[max_index+i] + 1) / 2;
//	}
//	cout << sum << endl;
//	return 0;
//}
int main()
{
	int n;
	cin >> n;
	//vector<int> a(n);
	bool approved = true;
	rep(i, n) {
		int input;
		cin >> input;
		if (input % 2 == 0) {
			if (input % 3 != 0 && input % 5 != 0) {
				approved = false;
			}
		}
	}
	string ans = approved ? "APPROVED" : "DENIED";
	cout << ans << endl;
	return 0;
}

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

const int maxn=200010;
long bit[maxn], c[maxn];
pair<long, int> b[maxn];

auto sum(int i)
{
    long res=0;
    while (i>0) { res+=bit[i]; i-=i&-i; }
    return res;
}
void add(int i, int x)
{
    while (i<maxn) { bit[i]+=x; i+=i&-i; }
}
int main()
{
    int n, k; cin>>n>>k;
    for(long s=0, i=1; i<=n; ++i) {
        int a; cin>>a;
        s+=a;
        b[i]={s-i*k, i};
    }
    sort(b, b+n+1);
    for(int i=0; i<=n; ++i) c[b[i].second]=i+1;

    long res=0;
    for(int i=0; i<=n; ++i) {
        res+=sum(c[i]);
        add(c[i], 1);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6528
n, y = map(int, input().split())
existence = False
for i in range(n+1):
    for j in range(n+1-i):
        k = (y - 10000*i - 5000*j)/1000
        if k == n-i-j:
            print(i, j, int(k))
            existence = True
            break
    else:
        continue
    break

if not existence:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using namespace std;

int main(){
    string s;
    vector<int> a(26, 0);

    cin >> s;
    for (int i = 0; i < s.size();i++){
        int tmp = s[i] - 'a';
        a[tmp]++;
    }

    for (int i = 0; i < 26;i++){
        if(a[i]==0){
            cout << char(i + 'a');
            return 0;
        }
    }
    cout << "None";
}

Measured memory_bytes: 512
from math import inf


def main(N, A, B, C, D):
    if N == 1:
        return D
    if N in dp:
        return dp[N]
    r = inf
    if N % 2 != 0:
        r = min(
            A + main(N // 2 + 1, A, B, C, D) + D,
            A + main(N // 2, A, B, C, D) + D,
            r
        )
    else:
        r = min(
            A + main(N // 2, A, B, C, D),
            r
        )
    if N % 3 != 0:
        r = min(
            B + main(N // 3 + 1, A, B, C, D) + (3 - N % 3) * D,
            B + main(N // 3, A, B, C, D) + (N % 3 * D),
            r
        )
    else:
        r = min(
            B + main(N // 3, A, B, C, D),
            r
        )
    if N % 5 != 0:
        r = min(
            C + main(N // 5 + 1, A, B, C, D) + (5 - N % 5) * D,
            C + main(N // 5, A, B, C, D) + (N % 5 * D),
            r
        )
    else:
        r = min(
            C + main(N // 5, A, B, C, D),
            r
        )
    r = min(N * D, r)
    dp[N] = r
    return r

T = int(input())
q_list = [[int(s) for s in input().split()] for _ in range(T)]
for q in q_list:
    dp = {0: 0}
    print(main(*q))

Measured memory_bytes: 91748
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  VI a(n),b(n);
  rep(i,n)cin >> a.at(i) >> b.at(i);
  int cnt=0;
  rep(i,n){
    if(a.at(i)>=h && b.at(i)>=w)cnt++;
  }
  cout << cnt << endl;
    
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
import sys
from collections import defaultdict
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def solve(S: str):
    if len(S) < 4:
        print(0)
        exit()
    prev = int(S[-1])
    digit = 10
    count = defaultdict(int)
    for i in range(1,len(S)+1):
        k = prev % 2019
        # print(prev)
        count[k]+=1
        if i == len(S):
            break
        prev = (prev + digit*int(S[-i-1]))%2019
        digit=digit*10%2019
    sum = 0
    for k in count:
        if k == 0:
            sum += count[k]
            if count[k] >= 2:
                sum += combinations_count(count[k], 2)
            continue
        if count[k] < 2:
            continue
        sum += combinations_count(count[k],2)
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens) # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10040
# coding: utf-8

n = int(input())
s = input()

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
            "v", "w", "x", "y", "z"]

max_count = 0

for i in range(1, n):
    left = s[0:i]
    right = s[i:n]
    count = 0
    for x in alphabet:
        if left.find(x) != -1 and right.find(x) != -1:
            count += 1
    if max_count < count:
        max_count = count
        
print(max_count)

Measured memory_bytes: 3064
#include<stdio.h>
long long int x,y;
long long int m,n;
long long int ans1,ans2;

int GCD(long long int n,long long int m){
    if(n%m==0){
        return m;
    }
    return GCD(m,n%m);
}

int main(){
    while(1){
        if(scanf("%lld",&n)==-1)break;
        scanf("%lld",&m);
        if(n<=m){
            ans1=GCD(m,n);
        }
        else{
            ans1=GCD(n,m);
        }
        ans2=m*n/ans1;
        printf("%lld %lld\n",ans1,ans2);
    }
    return 0;
}

Measured memory_bytes: 1024
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2187"

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

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename F>
void all_permutations(int n,F f){
  vector<int> vs(n);
  iota(vs.begin(),vs.end(),0);
  do f(vs); while(next_permutation(vs.begin(),vs.end()));
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed ABC054_C(){
  int n,m;
  cin>>n>>m;
  int es[10][10]={};
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    es[a][b]=es[b][a]=1;
  }
  int ans=0;
  auto f=
    [&](const auto &vs){
      if(!es[0][vs[0]+1]) return;
      for(int i=0;i+1<n-1;i++)
        if(!es[vs[i]+1][vs[i+1]+1]) return;
      ans++;
    };
  all_permutations(n-1,f);
  cout<<ans<<endl;
  return 0;
}
/*
  verified on 2019/12/09
  https://atcoder.jp/contests/abc054/tasks/abc054_c
*/

signed main(){
  ABC054_C();
  return 0;
}
#endif

#undef call_from_test

#define ERROR "1e-5"

signed solve(){
  const int n=9;
  vector<int> as(n),bs(n);
  for(int i=0;i<n;i++) cin>>as[i];
  for(int i=0;i<n;i++) cin>>bs[i];
  int num=0,cnt=0;
  auto f=
    [&](vector<int> vs){
      int x=0,y=0;
      for(int i=0;i<n;i++){
        if(as[vs[i]]<bs[i]) x+=as[vs[i]]+bs[i];
        if(as[vs[i]]>bs[i]) y+=as[vs[i]]+bs[i];
      }
      if(x<y) num++;
      cnt++;
    };
  all_permutations(n,f);

  double A=(double)num/cnt;
  double B=1.0-A;
  cout<<fixed<<setprecision(5);
  cout<<A<<" "<<B<<endl;
  return 0;
}

signed main(){
  int T;
  cin>>T;
  while(T--) solve();
  return 0;
}



Measured memory_bytes: 3228
<?php

list($N,$M,$C)=explode(" ",trim(fgets(STDIN)));
$B=explode(" ",trim(fgets(STDIN)));
$count=0;


for($j=0;$j<$N;$j++){

    $A=explode(" ",trim(fgets(STDIN)));
    $sum=0;

    for($i=0;$i<$M;$i++){
        $sum+=$A[$i]*$B[$i];
    }
  
    $sum+=$C;
   
    if($sum>0){
        $count++;
    }
}

echo $count;
?>

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    if(n > 0){
        ans += (n * (n - 1)) / 2;
    }
    if(m > 0){
        ans += (m * (m - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a==b){
    cout << "Draw";
  }
  else if(a>b){
    if(b==1){
      cout << "Bob";
    }
    else{
      cout << "Alice";
    }
  }
  else if(a<b){
    if(a==1){
      cout << "Alice";
    }
    else{
      cout << "Bob";
    }
  }
  cout << endl;
  return 0;
}

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

int main(void) {
    int N;
    std::string s, t;
    std::cin >> N >> s >> t;
    
    int l = -1; 
    for(int i = 0; i < N; i++){
        bool match = true;
        for(int j = 0; j < N - i; j++){
            if(s[j+i] == t[j] && match == true) {
                match = true;
            } else {
                match = false;
            }
        }
        if(match == true) {
            l = i;
            break;
        }
    }
    if(l == -1) l = N;
    std::cout << N+l << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long read(){
	long long x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
int main(){
	long long n=read(),m=read();
	long long x=n,cnt=1;
	while (x<m){
		if (x*2<=m) cnt++;
		x*=2;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128