akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"log"
	"math"
	"os"
	"strconv"
    "fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
    s := nextString()
    t := nextString()
    fmt.Println(t+s)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';
ll i, j, le;
int main()
{
  IOS;
  int t;
  t = 1;
  while (t--)
  {ll a;
    cin>>a;
if(a)cout<<0;
else cout<<1;
  }
  return 0;
}


Measured memory_bytes: 3600
#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);
    ll n,m,i;
    cin>>n>>m;
    if(n<=m){
        for(i=1;i<=m;i++){
            cout<<n;
        }
    }
    else{
        for(i=1;i<=n;i++){
            cout<<m;
        }
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')
import bisect

def solve():
    n = II()
    L = LI()
    L = sorted(L)

    ans = 0
    for i in range(n):
        li = L[i]
        for j in range(i+1, n):
            lj = L[j]
            ab = li + lj
            l_idx = j + 1
            r = li + lj
            # c = [l_idx, r_idx)
            r_idx = bisect.bisect_left(L, r)
            # print(li, lj, l_idx, r_idx)
            ans += r_idx - l_idx
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int n,T,d;
	cin>>n;
	vi t(n+1),x(n+1),y(n+1);
	t[0]=x[0]=y[0] = 0;
	for1(i,n){
		cin>>t[i]>>x[i]>>y[i];
		}
	for0(i,n){
		T = t[i+1] - t[i];
		d = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
		if(d>T || d%2 != T%2){ pf("No"); return 0; }
		}
	pf("Yes");
	
	return 0;
}

Measured memory_bytes: 4536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n,p; cin>>n;
ll a[n]={};
ll b[n]={};
ll ca=0;
ll cb=0;
ll k=0;
ll c[n]={};
rep(i,n){
cin>>a[i]>>b[i];
cb+=b[i];
c[i]=a[i]+b[i];}
sort(c,c+n);
if(n%2==0){
rep(i,n){
if(i%2==0){
k++;}
else{
ca+=c[i];}
}}
else{
rep(i,n){
if(i%2==0){
ca+=c[i];
}
else{
k++;
}
}}
ll ans = ca - cb;
cout << ans << endl;}


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

const int INF = 1<<28;
int N;
string A, B;

int rec(vector<int> v) {
  if(v.empty()) return 0;
  if(v[0] == 0) {
    return rec(vector<int>(v.begin()+1, v.end()));
  }
  int d = -v[0];
  int res = INF;
  for(int i = 0; i < v.size(); ++i) {
    v[i] = (v[i] + d + 10) % 10;
    res = min(res, rec(vector<int>(v.begin()+1, v.end())) + 1);
  }
  return res;
}

int main() {
  while(cin >> N && N) {
    cin >> A >> B;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
      v[i] = (B[i] - A[i] + 10) % 10;
    }
    cout << rec(v) << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
	int c;
	cin>>c;
  for(int i=1; i<10;i++){
  	for(int j=1;j<10;j++){
  		if(i*j==c){
        cout<<"Yes";
        return 0;
        }
  	}
  }
  cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7


int main(){
    int n;
    cin >> n;
    ll a[100002];
    map<ll, ll>mp;
    REP(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll first, second;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr -> second < 2)continue;
        if(itr -> second >= 4){
            first = itr -> first;
            second = itr -> first;
        }else{
            second = first;
            first = itr -> first;
        }
    }
    print(first * second);

}

Measured memory_bytes: 7296
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int n,x,ans;
	char s[105];
	while(~scanf("%d",&n)){
		x = 0;ans = 0;
		scanf("%s",s);
		for(int i = 0;i < n;i++){
			if(s[i] == 'I') x++;
			else if(s[i] == 'D') x--;
			ans = max(x,ans);
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	string S;
	cin >> S;

	const int n = S.size();
	vector<char> c;
	vector<long long> d;

	for (int i = 0; i < n; ++i) {
		if (!c.empty() && S[i] == c.back()) {
			++d.back();
		}
		else {
			c.push_back(S[i]);
			d.push_back(1);
		}
	}

	const int m = c.size();

	long long ans = 0;
	if (c[0] == '>') {
		ans += d[0];
	}
	for (int i = 0; i + 1< m; ++i) {
		if (c[i] == '<' && c[i + 1] == '>') {
			ans += max(d[i], d[i + 1]);
		}
	}
	if (c[m - 1] == '<') {
		ans += d[m - 1];
	}
	for (int i = 0; i < m; ++i) {
		ans += d[i] * (d[i] - 1) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3196
N = int(input())


## アナグラム的に一致した回数を辞書に格納
dict_s = {}
for n in range(N):
  _ = ''.join(sorted(input()))
  if _ in dict_s:
    dict_s[_] += 1
  else:
    dict_s[_] = 1

## 組み合わせ数を計算
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

cnt_anagram = 0
for v in dict_s.values():
  if v > 1:
  	cnt_anagram += cmb(v, 2)

## 出力
print(cnt_anagram)

Measured memory_bytes: 17852
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


lli power(lli x,lli y,lli m)
{
    lli res=1;
    while(y>0)
    {
        if(y&1)res=((res%m)*(x%m))%m;
        y>>=2;
        x= ((x%m)*(x%m))%m;
    }
    return res%m;
}

int main()
{
    
                        
     fio

     
     lli a;
     cin>>a;
     cout<<(a)+(a*a)+(a*a*a);




      
     

     
              


return 0;}    


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<int> a(n);
	cin >> a;
	vector<ll> rec(n), rec_(n);
	rep(i, n) {
		rep(j, n) {
			if (i < j) {
				if (a[i] > a[j]) rec[i]++;
			}
			if (a[i] > a[j]) rec_[i]++;
		}
	}
	ll ans = 0;
	rep(i, n) {
		ll tmp = k * rec[i];
		tmp %= mod;
		tmp += ((k * (k - 1) / 2) % mod) * rec_[i];
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

string intstring(int n, int L){
  string s="";
  int pow=1;
  for(int i=0;i<L-1;i++)pow*=10;
  for(;pow;pow/=10){
    s += '0' + n/pow;
    n %= pow;
  }
  return s;
}

int stringint(string s){
  int n=0;
  int pow=1;
  for(int i=0;i<s.size();i++){
    n += pow * (s[s.size()-i-1]-'0');
    pow*=10;
  }
  return n;
}

int main()
{
  int A,L;
  while(cin>>A>>L,A|L){
    vector<string>used;
    string s = intstring(A,L);
    string large,small;
    used.push_back(s);
    bool find=false;
    for(int i=0;!find;i++){
      small = large = s;
      sort(small.begin(),small.end());
      sort(large.begin(),large.end(),greater<char>());
      s = intstring( stringint(large)-stringint(small), L );
      for(int j=0;j<used.size();j++){
	if(used[j]!=s)continue;
	find = true;
	cout<<j<<" "<<stringint(s)<<" "<<i-j+1<<endl;
      }
      used.push_back(s);
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c){
    cout<<1<<'\n';
  }
  else if(a==b && b!=c){
    cout<<2<<'\n';
  }
  else if(a!=b && b==c){
    cout<<2<<'\n';
  }
  else if(a!=b && a==c){
    cout<<2<<'\n';
  }
  else if(a==b && a!=c){
    cout<<2<<'\n';
  }
  else if(b==c && a!=c){
    cout<<2<<'\n';
  }
  else if(a==c && a!=c){
    cout<<2<<'\n';
  }
  else if(a!=b && b!=c && a!=c){
    cout<<3<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    ll S;
    cin >> S;
    ll q = S / (ll)1e9;
    ll r = S % (ll)1e9;
    if (r == 0) {
        cout << "0 0 " << (ll)1e9 << " 1 " << r << " " << q << endl;
    } else {
        cout << "0 0 " << (ll)1e9 << " 1 " << (ll)1e9 - r << " " << q + 1 << endl;
    }
}


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

int main(){
    ll n, count=0, ans=0, point;
    cin >> n;
    vector<ll> A(n);
    RAP(i,n){
        cin >> A[i];
        if(A[i]<0){
            count++;
            A[i] = abs(A[i]);
        }
    }
    sort(A.begin(), A.end());
    RAP(i,n){
        ans += abs(A[i]);
    }
    if(count%2==1){
        ans -= abs(A[0])*2;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int countSurroundingBomb(int h, int w, int lh, int lw, char** grid);
bool isSpace(int h, int w, char** grid);
char fromInt(int n);

int main() {
  int h, w;
  cin >> h >> w;
  char** grid = new char*[h];
  for(int i = 0; i < h; i++)
    grid[i] = new char[w];
  
  //input
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> grid[i][j];
  
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(isSpace(i, j, grid) != false)
        grid[i][j] = fromInt(countSurroundingBomb(h, w, i, j, grid));
  
  //output
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++)
      cout << grid[i][j];
    cout << endl;
  }
  
  //release  
  for(int i = 0; i < h; i++)
    delete[] grid[i];
  delete[] grid;
}
bool isSpace(int h, int w, char** grid) {
  if(grid[h][w] == '.')
    return true;
  else return false;
}
char fromInt(int n) {
  switch(n) {
    case 0 : return '0';
    case 1 : return '1';
    case 2 : return '2';
    case 3 : return '3';
    case 4 : return '4';
    case 5 : return '5';
    case 6 : return '6';
    case 7 : return '7';
    case 8 : return '8';
  }
}
int countSurroundingBomb(int h, int w, int lh, int lw, char** grid) {
  int cnt = 0;
  for(int i = -1; i <= 1; i++)
    for(int j = -1; j <= 1; j++) {
      int llh = lh + i, llw = lw + j;
      if(llh < 0 || llh > h - 1 || llw < 0 || llw > w - 1)
        continue;
      else if(i == 0 && j == 0)
        continue;
      if(grid[llh][llw] == '#')
        ++cnt;
    }
  return cnt;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int N, K;
	string S;
	cin >> N >> K >> S;
	S[K - 1] = ::tolower(S[K - 1]);
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
w=[]
n.times do
  w << gets.chomp.split('')
end
for i in 1..n-1 do
  if w[i][0] == w[i-1][-1] then
    for j in 0..i-1 do
      if w[j] == w[i]
        puts 'No'
        exit
      end
    end
  else
    puts 'No'
    exit
  end
end
puts 'Yes'

Measured memory_bytes: 1916
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] T = new long[N];
    long[] A = new long[N];
    for (int i =0; i<N; i++) {
      T[i] = sc.nextInt();
      A[i] = sc.nextInt();
    }
    for (int i =0; i<N-1; i++) {  
      if (A[i+1] < A[i] || T[i+1] < T[i]) {
        long a = Math.max((A[i]+A[i+1]-1)/A[i+1],(T[i]+T[i+1]-1)/T[i+1]);
        A[i+1] *= a;
        T[i+1] *= a;
      }
    }
    System.out.println(A[N-1] + T[N-1]);
  }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
 string s,t;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>s>>t;
  
  
  cout<<t+s<<"\n";
}

signed main(){
     
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

const int N = 1e5 + 5;

int n, a, b;
string s;
int passed = 0;
int idx = 1;
vector<string> ans;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

     cin >> n >> a >> b >> s;
     
     for (int i = 0; i < s.size(); i++){
      if (s[i] == 'a' && passed < a + b){
        ans.push_back("Yes");
        passed++;
      }
      else if (s[i] == 'b' && passed < a + b){
        if (idx <= b){
          ans.push_back("Yes");
          passed++;
          idx++;
        }
        else
          ans.push_back("No");
      }
      else
        ans.push_back("No");
     }
     for (auto it : ans)
      cout << it << endl;

}

Measured memory_bytes: 6212
#include <stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  int A[N];
  for(int i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  int syonin = 1; //0で非承認
  for(int j=0; j<N; j++){ //入国審査
    if((A[j]%2) == 0){ //偶数であり
      if((A[j]%3) == 0 || (A[j]%5) == 0){ //3or5で割り切れるなら承認
      }else{
        syonin = 0;
      }
    }
  }
  if(syonin == 1){
    printf("APPROVED");
  }else{
    printf("DENIED");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main(){
    int n;
    cin >> n;

    vector<double> v(n, 0);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double sum = 0;
    for(int i = 0; i < n; i++){
        if(i != 0){
            sum += pow(2, i - 1) * v[i]; 
        }
        else{
            sum += v[i];
        }    
    }
    cout << fixed << setprecision(6);
    cout << sum / pow(2, n - 1) << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a[105];
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cout << a[i] << (i == n - 1 ? '\n' : ' ');
	int k;
	for (int i = 1; i < n; i++) {
		k = a[i];
		int j;
		for (j = i - 1; j<n&&a[j] > k; j--)
			a[j + 1] = a[j];
		a[j + 1] = k;
		for (int i = 0; i < n; i++)
			cout << a[i] << (i == n - 1 ? '\n' : ' ');
	}
	return 0;
}

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

using namespace std;

int main()
{
	int x;
	cin >> x;
	
	int coins500 = x / 500;
	int rest500 = x % 500;
	int coins5 = rest500 / 5;

	cout << coins500 * 1000 + coins5 * 5 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a[3];
  cin >> a[0]>> a[1]>> a[2];
  sort(a,a+3);
  int sum=a[0]+a[1]+a[2];
  if((a[2]*3)%2==sum%2){
    cout <<((a[2]*3)-sum)/2<<endl;
  }
  else{
    a[2]++;
    cout <<((a[2]*3)-sum)/2<<endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
x = 0
for i in range(n-1):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            x += 1
y = 0
mod = 10 ** 9 + 7
for i in range(n):
    for j in c.keys():
        if j < a[i]:
            y += c[j]
print((((y*k*(k-1)//2 ))+(k*x)%mod)%mod)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;

		int cnt = 0, ma = a*a + b*b;
		for(int i=0; i*i <= ma; ++i) {
			for(int j=0; i*i+j*j <= ma; ++j) {
				if(i*i + j*j == 0) continue;
				if((i*a + j*b) % (i*i+j*j) == 0 && (i*b-j*a)%(i*i+j*j) == 0) cnt++;
				if(i != 0 && (-i*a + j*b) % (i*i+j*j) == 0 && (-i*b-j*a)%(i*i+j*j) == 0) cnt++;
				if(j != 0 && (i*a - j*b) % (i*i+j*j) == 0 && (i*b+j*a)%(i*i+j*j) == 0) cnt++;
				if(i != 0 && j != 0 && (-i*a - j*b) % (i*i+j*j) == 0 && (-i*b+j*a)%(i*i+j*j) == 0) cnt++;
			}
		}

	if(cnt == 8) cout << "P" << endl;
	else cout << "C" << endl;
	}

	return 0;
}

Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include<atcoder/all>

using namespace std;

using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }


void solve() {
	int T; cin >> T;
	REP(_, T) {
		int N, M, A, B; cin >> N >> M >> A >> B;
		print(floor_sum(N, M, A, B));
	}
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,a[100005];ll ans;
int main()
{
    fastio;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i+1<=n;i+=2) if(a[i]+a[i+1]<0) ans+=-a[i]-a[i+1];else ans+=a[i]+a[i+1];
    if(n%2==1) ans+=a[n];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

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

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  string s;
  cin >> s;
  cout << s.substr(0,3);
}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  //cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



Measured memory_bytes: 3580
#include<stdio.h>

int n,A[50];

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

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

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

  return 0;
}

Measured memory_bytes: 580
import sys
import re
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans)


def main():
    S = input()

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49372
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, long long> cnt;
    for (auto &&i : a)
    {
        cin >> i;
        cnt[i]++;
    }
    long long ans = 0;
    for (auto &&i : cnt)
    {
        ans += i.second * (i.second - 1) / 2;
    }
    for (auto &&i : a)
    {
        cout << ans - cnt[i] + 1 << "\n";
    }
}

Measured memory_bytes: 10240
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str0,str1;
    cin>>str0>>str1;
    str0+=str0;
    if(str0.find(str1)!=string::npos){
        cout<<"Yes"<<endl;
        
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


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

//Matrix Exponentiation
lli mod=1e9+7;
struct matrix //1 base index change if needed
{
    lli ara[55][55];
    int n,m;
    matrix(int n_,int m_)
    {
        n=n_;
        m=m_;
        memset(ara,0,sizeof ara);
    }
    matrix operator *(matrix a) // for multiplication
    {
        matrix ret(n,a.m);
        int nn=n;
        int mm=a.m;
        for(int i=1; i<=nn; i++)
           for(int j=1; j<=mm; j++)
               for(int k=1; k<=a.n; k++)
                {
                    ret.ara[i][j]+=(ara[i][k]*a.ara[k][j])%mod;
                    if(ret.ara[i][j]>=mod)
                    ret.ara[i][j]=(ret.ara[i][j])%mod;
                }
        return ret;
    }
    void show()  // for printing the matrix not necessary
    {
     for(int i=1; i<=n; i++,cout <<endl)
            for(int j=1; j<=m; j++)
                cout <<ara[i][j]<<" ";
    }
};
matrix identity(int n) // identity matrix
{
    matrix ret(n,n);
    for(int i=1; i<=n; i++)
        ret.ara[i][i]=1;
    return ret;
}
matrix big_modm(matrix x,lli n) //iterative bigmod
{
  matrix ret=identity(x.n);
  matrix temp=x;
  while(n)
   {
      if(n&1)
      ret=(ret*temp);
      temp=(temp*temp);
      n=n>>1;
   }
  return ret;
}

int main()
{

   long long n,k;
   cin>>n>>k;

   matrix mat(n,n);
   for(int i=1;i<=n;i++)
   {
     for(int j=1;j<=n;j++)
     {
     cin>>mat.ara[i][j];
     }
   }

   mat=big_modm(mat,k);
   long long ans=0;
    for(int i=1;i<=n;i++)
   {
     for(int j=1;j<=n;j++)
     {
     ans+=mat.ara[i][j];
     if(ans>=mod)
     ans%=mod;
     }
   }


   cout <<ans;

}



Measured memory_bytes: 384
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

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

    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vi l(Q), r(Q); REP(i, Q) cin >> l[i] >> r[i];

    vi sum(N, 0);

    // Cumulative sum
    FOR(i,1,N) {
        if (S[i-1] == 'A' && S[i] == 'C') {
            sum[i] = sum[i - 1] + 1;
        } else {
            sum[i] = sum[i - 1];
        }
    }

    REP(i,Q) {
        int ans = sum[r[i]-1] - sum[l[i]-1];
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
    int64_t n, m;
    cin >> n >> m;
    if (n >= 2) {
        n -= 2;
    }
    if (m >= 2) { 
        m -= 2;
    }
    int64_t answer = n * m;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    string s,t;
    cin>>s>>t;
    bool flag=false;
    rep(i,s.size()-1){
        if(s==t){
            flag=true;
        }
        char las=s.at(s.size()-1);
        s=las+s;
        s.erase(s.end()-1);
    }
  	if(s==t){
      flag=true;
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
  int ans;
int N,K; cin>>N>>K;
  vector<int>P(N);
  rep(i,K){
  int d; cin>>d;
    rep(i,d){
    int a; cin>>a;
      P.at(a-1)=1;
    }
  }
  
  rep(i,N){
  if(P.at(i)==0){ans++;}
  else continue;}
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <complex>
#include <bitset>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

int N, a[2020];
int sum = 0;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	REP(i, N){
		cin >> a[i];
		sum += a[i];
	}
	bitset<4000400> bs;
	bs[0] = 1;
	REP(i, N){
		bs |= bs<<a[i];
	}
	REP(i, sum+1){
		if((sum+1)/2 <= i && bs[i] == 1){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1792
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
A = na()

if A[0] == 1 and n == 0:
    print(1)
    exit()

if A[0] > 0:
    print(-1)
    exit()

dp = [1]*(n+1)
pd = [1]*(n+1)

m = 1
for i in range(1,n+1):
    m = m*2
    dp[i] = m
    m -= A[i]
    if m < 0:
        print(-1)
        exit()

m = 0
for i in range(0,n+1)[::-1]:
    m+=A[i]
    pd[i] = m

ans = []
for i in range(n+1):
    ans.append(min(dp[i],pd[i]))
    
print(sum(ans))

Measured memory_bytes: 708012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B;
    cin >> A >> B;
    vector<vector<char>> G(100,vector<char>(100,'.'));
    rep(i,50){
        rep(j,100){
            G[i][j] = '#';
        }
    }
    ll cntA=0, cntB=0;
    bool flag = false;
    rep(i,50){
        rep(j,100){
            if(cntA == A-1){
                flag = true;
                break;
            }
            G[i][j] = '.';
            cntA++;
            j++;
        }
        if(flag) break;
        i++;
    }
    flag = false;
    REP(i,51,100){
        rep(j,100){
            if(cntB == B-1){
                flag = true;
                break;
            }
            G[i][j] = '#';
            cntB++;
            j++;
        }
        if(flag) break;
        i++;
    }
    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100){
            cout << G[i][j];
        }
        cout << endl;
    }
}   

Measured memory_bytes: 3656
#include <bits/stdc++.h> 
    using namespace std; 
    using namespace std::chrono; 
    #define ll long long int 
     
    int main() 
    { 
    	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    	
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n;
        cin>>n;
        vector<ll>v;
        ll flag=0;
        while(n--){
            ll temp;
            cin>>temp;
            if(temp%2==0){
                if(temp%3!=0&&temp%5!=0)
                    flag=1;
                    
            }
        }
        if(flag==1)
            cout<<"DENIED"<<endl;
        else
            cout<<"APPROVED"<<endl;
    	return 0; 
    } 
     


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N;

  cin >> N;

  if(N == 1) cout << "Hello World" << "\n";
  else if(N == 2){
    int A,B;
    cin >> A >> B;
    cout << A+B << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int main(){
while(1){
	int n,m,h,k,r[1002],p[1002],e[1002],c,d,ans=0,ma=0;
	vector<int> a[1000],aa,bb;
	scanf("%d%d%d%d",&n,&m,&h,&k);
if(n==0)break;
	for(int i=1;i<=n;i++){r[i]=i; scanf("%d",&p[i]);}
	for(int i=0;i<m;i++){
		scanf("%d%d",&c,&d);
		a[d].push_back(c);
	}
	for(int i=0;i<1000;i++){
		int s=a[i].size();
		for(int j=0;j<s;j++){
			aa.push_back(r[a[i][j]]);
			bb.push_back(r[a[i][j]+1]);
			int t=r[a[i][j]];
			r[a[i][j]]=r[a[i][j]+1];
			r[a[i][j]+1]=t;
		}
	}
	for(int i=1;i<=n;i++){
		e[r[i]]=i;
	}
	for(int i=1;i<=k;i++){
		ans+=p[e[i]];
	}
	for(int i=0;i<m;i++){
		if(aa[i]<=k&&bb[i]>k&&(p[e[aa[i]]]-p[e[bb[i]]])>ma)ma=p[e[aa[i]]]-p[e[bb[i]]];
		else if(bb[i]<=k&&aa[i]>k&&(p[e[bb[i]]]-p[e[aa[i]]])>ma)ma=p[e[bb[i]]]-p[e[aa[i]]];
	}
	printf("%d\n",ans-ma);
}
}

Measured memory_bytes: 2756
import queue

def main():
    k = int(input())
    q = queue.Queue()
    for i in range(1, 10):
        q.put(str(i))
    ans = ""
    for i in range(1, k+1):
        ans = q.get()
        if i < k:
            p = int(ans[-1])
            if p == 0:
                q.put(ans + "0")
                q.put(ans + "1")
            elif p == 9:
                q.put(ans + "8")
                q.put(ans + "9")
            else:
                for v in range(p-1, p+2):
                    q.put(ans + str(v))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 22688
using System;

	public class Class1
	{
		public static void Main()
		{  
			string answer=Console.ReadLine();//string
			int numOrders=int.Parse(Console.ReadLine());//number of orders
			
			for(int i=0;i<numOrders;i++)
			{
				string order=Console.ReadLine();
				string[] oab=order.Split();
				int a=int.Parse(oab[1]);//0~
				int b=int.Parse(oab[2]);//0~
				
				switch (oab[0])
				{
					case "print":
						string print =answer.Substring(a,b-a+1);
						Console.WriteLine(print);
						break;
					case "reverse":
						char[] ans=new char[b-a+1];
						for(int j=0;j<b-a+1;j++)
						{							
							ans[j]=answer[b-j];
						}
						string temp=new string(ans);
						if(a==0)
						{
							answer=temp+answer.Substring(b+1);
						}
						else{
						answer=answer.Substring(0,a)+temp+answer.Substring(b+1);
						}
						break;
						
					case "replace":
						if(a==0)
						{
							answer=oab[3]+answer.Substring(b+1);
						}
						else{
						answer=answer.Substring(0,a)+oab[3]+answer.Substring(b+1);
						}
						break;
				}
					
			}
		}
	}

Measured memory_bytes: 9124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKnapsack1 solver = new DKnapsack1();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnapsack1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int W = in.nextInt();
            long[][] dp = new long[N + 1][W + 1];
            for (int i = 1; i <= N; i++) {
                int wi = in.nextInt();
                long vi = in.nextInt();
                for (int j = 0; j <= W; j++) {
                    dp[i][j] = (j >= wi) ? Math.max(dp[i - 1][j], dp[i - 1][j - wi] + vi) : dp[i - 1][j];
                }
            }
            out.print(dp[N][W]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 125780
///////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
///////////////////////////////////////////
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <vector>        // vector
#define rep(i, n) for (long long i = 0; i < n; i++)
#define ll long long
using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  ll a;
  cin>>a;
  ll power=1;
  rep(i,a){
    power=(power*(i+1))%1000000007;
  }

  cout<<power<<endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0);
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k<=a) cout << k << endl;
	else if(k<=a+b&&k>a) cout << a << endl;
	else if(k<=a+b+c&&k>a+b) cout << a-(k-a-b) << endl;
	return 0;	
} 

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(Math.max((n - 2) * b - (n - 2) * a + 1, 0));
    }

}


Measured memory_bytes: 23252
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

bool calc(int rows, int cols, int k) {
    for (int i = 0; i <= rows; i++) {
        for (int j = 0; j <= cols; j++) {
            int n = (cols - j) * i + (rows - i) * j;
            if (n == k)
                return true;
        }
    }
    return false;
}

void main() {
    auto xs = readints;
    int n = xs[0], m = xs[1], k = xs[2];

    writeln(calc(n, m, k) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
const ll  oo = 1e9 + 1;
const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 5;

ll n, i, j, flag[1000001], res(1);
bool prime[1000001];
vector <int> v;

void Init()
{
    cin >> n;
    fill (prime + 1, prime + n + 1, 1);
    for (i = 2; i * i <= n; ++i)
        for (j = 2; j * i <= n; ++j) prime[i * j] = 0;
    for (i = 2; i <= n; ++i) if (prime[i]) v.push_back(i);
    for (i = 2; i <= n; ++i)
    {
        ll u = i;
        while (u > 1)
        {
            for (int l : v)
                if (u % l == 0)
                {
                    flag[l]++; u /= l; break;
                }
        }
    }
    for (i = 2; i <= n; ++i)
        if (prime[i]) res = res * (flag[i] + 1) % mod;
    cout << res;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("C-Factors of Factorial.inp", "r", stdin);
    //freopen("C-FactorsofFactorial.out", "w", stdout);

	Init();
}
//Date 10 Month 7 Year 2017





Measured memory_bytes: 256