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

#define INF 1000000000

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    long x[N];
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    int l_lim = lower_bound(x, x + N, 0) - x;
    int u_lim = upper_bound(x, x + N, 0) - x;
    long ans = INF;
    long temp = INF;
    for(int i=0; i<=l_lim; i++){
        if(i + K -1 < N && x[max(u_lim-1, 0)] <= x[i+K-1]){
            if(x[i] * x[i+K-1] < 0) temp = min(abs(x[i]) + x[i+K-1] * 2, abs(x[i]) * 2 + x[i+K-1]);
            else temp = max(abs(x[i]), x[i+K-1]);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int k;

	cin >> k;

	string s;
	cin >> s;

	if (s.length() <= k) {
		cout << s << endl;
	}
	else {
		string ans = s.substr(0, k) + "...";
		cout << ans << endl;
	}
	return 0;
}


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

int main()
{
    vector<int> ans;
    while (1)
    {
        int n, m;
        cin >> m >> n;
        if (n == 0 && m == 0)
        {
            break;
        }
        vector<bool> isPrime(7368792, true);
        for (int i = m; i <= 7368791; i++)
        {
            if (isPrime[i])
            {
                for (int j = 2; i * j <= 7368791; j++)
                {
                    isPrime[i * j] = false;
                }
            }
        }
        int count = 0;
        for (int i = m; i <= 7368791; i++)
        {
            if (isPrime[i] && count <= n - 1)
            {
                count++;
            }
            else if (isPrime[i] && count > n - 1)
            {
                ans.push_back(i);
                break;
            }
        }
        //     vector<int> bambooList;
        //     bambooList.push_back(m);

        //     int i = 1;

        //     while (bambooList.size() < n + 1)
        //     {
        //         int judging = m + i;

        //         bool isNotInList = false;
        //         for (int j = 0; (bambooList[j] * bambooList[j] <= judging); ++j)
        //         {
        //             if (judging % bambooList[j] == 0)
        //             {
        //                 isNotInList = true;
        //                 break;
        //             }
        //         }

        //         if (!isNotInList)
        //         {
        //             bambooList.push_back(judging);
        //         }

        //         ++i;
        //     }

        //     ans.push_back(bambooList[n]);
    }

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


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double angleh=0.5*(60*h+m);
    double anglem=m*6;
    double diff=360-abs(angleh-anglem);
    diff=(pi*(double)diff)/180;
    cout<<setprecision(21)<<fixed<<sqrt(a*a+b*b-2*a*b*cos(diff))<<endl;
    return 0;
}


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

int main() {
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==a[2]) cout<<1<<endl;
  else if(a[0]==a[1] || a[1]==a[2]) cout<<2<<endl;
  else cout<<3<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct{
  int top_i;
  int top_j;
  double area;
}Stak;

int main(void){
  //posb->position(backslash),poss->position(slash)                                                                                                                                                       
  int i,j,k,len,posb,poss,bottom;
  double totalArea;
  char str[20000];
  int strPos[20002];/*now position*/
  Stak S2[10000];
  scanf("%s",str);
  len=strlen(str);
  posb=0;
  poss=0;
  strPos[0]=0;
  for(i=0,bottom=0;i<len;i++){
    if(str[i]=='\\')posb--;
    else if(str[i]=='/')poss++;
    strPos[i+1]=posb+poss;
    if(bottom>strPos[i+1])bottom=strPos[i+1];
  }
  /*calculation high of point*/
  for(i=0;i<=len;i++)
    strPos[i]-=bottom;

  /*calculation i and j*/
  for(i=0,k=0;i<=len;i++){
    if(str[i]=='\\'){
      j=i+1;

      while(1){
        if(strPos[i]==strPos[j]){
          S2[k].top_i=i;
          S2[k].top_j=j;
          i=j-1;
          k++;
          break;
        }
        j++;
        if(j>len+1)break;
      }

    }
  }
  
  for(i=0;i<k;i++){
    /*calculation area*/
    for(j=S2[i].top_i+1,S2[i].area=0;j<=S2[i].top_j;j++){

      if(str[i]=='_')S2[i].area+=strPos[S2[i].top_i]-strPos[j];

      else if(str[i]=='/' || str[i]=='\\'){
        if(strPos[S2[i].top_i]>strPos[j])
          S2[i].area+=strPos[S2[i].top_i]-strPos[j];
        else S2[i].area+=strPos[j]-strPos[S2[i].top_i];
      }

    }
  }

  for(i=0,totalArea=0;i<k;i++)
    totalArea+=S2[i].area;



  printf("%.0f\n",totalArea);
  printf("%d",k);
  if(k!=0)printf(" ");
  for(i=0;i<k;i++){
    printf("%.0f",S2[i].area);
    if(i!=k-1)printf(" ");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2144
x, y = map(int, input().split())
mod = 10 ** 9 + 7


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

if (x + y) % 3 != 0:
    print(0)
else:
    res = 0
    m, n = 0, 0
    while m * 2 <= x:
        n = x - m * 2
        if 2 * n + m == y:
            res += cmb(m + n, m, mod)
        m += 1
    print(res)

Measured memory_bytes: 122064
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

int d, n;
int t[200];
int c[200][3];
int dp[200][200];
const int INF = 100100100;

int main(){
	scanf("%d %d", &d, &n);
	for(int i=0; i<d; i++)
		scanf("%d", &t[i]);
	for(int i=0; i<n; i++)
		for(int j=0; j<3; j++)
			scanf("%d", &c[i][j]);

	for(int i=0; i<n; i++){
		if(c[i][0] <= t[0] && t[0] <= c[i][1]){
		}else{
			dp[0][i] = -INF;
		}
	}
	for(int i=1; i<d; i++){
		for(int j=0; j<n; j++){
			if(c[j][0] <= t[i] && t[i] <= c[j][1]){
				for(int k=0; k<n; k++){
					dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(c[j][2] - c[k][2]));
				}
			}
		}
	}
/*
	for(int i=0; i<d; i++){
		for(int j=0; j<n; j++)
			printf("%d\t", dp[i][j]);
		printf("\n");
	}
*/
	int ans = 0;
	for(int i=0; i<n; i++)
		ans = max(ans, dp[d-1][i]);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
int N;
int A[2*100000+100];
int main(int argc, char** argv, char** envp) {
  cin >> N;
  for(int i=0;i<N;++i) {
    scanf("%d", &A[i]);
  }
  
  ll answer = 0;
  int ac = 0;
  for(int i=0,j=0;i<N;++i) {
    while((ac&A[j])==0 && j < N) {
      ac ^= A[j++];
    }
    ac ^= A[i];
    answer += j-i;
  }
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
long long n,x,y,ans,s;
using namespace std;
int main()
{
	cin>>n>>x>>y;
	if(x>=n) 
	{
		cout<<"1";
		return 0;
	}
	if(y>=x) 
	{
		cout<<"-1";
		return 0;
	}
	if((n-x)%(x-y)>=1) s=1;
	cout<<((n-x)/(x-y)+s)*2+1;
}

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

string S;
vector<int> V[3];
int N, A[409], D[3][409];
int dp[409][409][409][3];

int main() {
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') A[i] = 0;
		if (S[i] == 'G') A[i] = 1;
		if (S[i] == 'Y') A[i] = 2;
		D[A[i]][i + 1] = 1;
		V[A[i]].push_back(i);
	}
	for (int i = 1; i <= N; i++) {
		D[0][i] += D[0][i - 1];
		D[1][i] += D[1][i - 1];
		D[2][i] += D[2][i - 1];
	}

	for (int i = 0; i <= D[0][N]; i++) {
		for (int j = 0; j <= D[1][N]; j++) {
			for (int k = 0; k <= D[2][N]; k++) {
				dp[i][j][k][0] = 1000000;
				dp[i][j][k][1] = 1000000;
				dp[i][j][k][2] = 1000000;
			}
		}
	}

	dp[0][0][0][0] = 0;
	dp[0][0][0][1] = 0;
	dp[0][0][0][2] = 0;
	for (int i = 0; i <= D[0][N]; i++) {
		for (int j = 0; j <= D[1][N]; j++) {
			for (int k = 0; k <= D[2][N]; k++) {
				if (i < D[0][N]) {
					int S1 = max(0, D[1][V[0][i]] - j);
					int S2 = max(0, D[2][V[0][i]] - k);
					dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], dp[i][j][k][1] + S1 + S2);
					dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], dp[i][j][k][2] + S1 + S2);
				}
				if (j < D[1][N]) {
					int S1 = max(0, D[0][V[1][j]] - i);
					int S2 = max(0, D[2][V[1][j]] - k);
					dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], dp[i][j][k][0] + S1 + S2);
					dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], dp[i][j][k][2] + S1 + S2);
				}
				if (k < D[2][N]) {
					int S1 = max(0, D[0][V[2][k]] - i);
					int S2 = max(0, D[1][V[2][k]] - j);
					dp[i][j][k + 1][2] = min(dp[i][j][k + 1][2], dp[i][j][k][0] + S1 + S2);
					dp[i][j][k + 1][2] = min(dp[i][j][k + 1][2], dp[i][j][k][1] + S1 + S2);
				}
			}
		}
	}

	int c0 = dp[D[0][N]][D[1][N]][D[2][N]][0];
	int c1 = dp[D[0][N]][D[1][N]][D[2][N]][1];
	int c2 = dp[D[0][N]][D[1][N]][D[2][N]][2];
	int val = min({ c0, c1, c2 });
	if (val == 1000000) cout << "-1" << endl;
	else cout << val << endl;
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    if (b == 1) goto last;
    while (count * (a - 1) + 1 < b) {
        count++;
    }
    last:
    cout << count << endl;
}


Measured memory_bytes: 256
from collections import Counter

def undivisible(A):
    m = max(A)
    dp = [True] * (m+1)
    A.sort()
    for a in A:
        if dp[a]:
            k = a * 2
            while k <= m:
                dp[k] = False
                k += a
    cnt = Counter(A)
    ans = 0
    for a in A:
        if dp[a] and cnt[a] == 1:
            ans += 1
    return ans

n = int(input())
A = list(map(int, input().split()))
print(undivisible(A))

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

      int X, Y, t, c, foot;
      cin >> X >> Y;


   for (c = 0; c <= X; c++) {
     t = X - c;
     foot = 2 * c + 4 * t;
     if (Y == foot){
       cout << "Yes" << endl;
       return 0;
     }
    }
      cout << "No" << endl;
       return 0;
   }

Measured memory_bytes: 3612
import java.util.*;
import java.io.*;

public class Main {


    public Main(FastScanner in, PrintWriter out) {
        int N = in.nextInt();
        long res = 0;
        Map<Integer, Integer> cnt = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = in.nextInt();
            res += cnt.getOrDefault(-a + i, 0);
            cnt.merge(a + i, 1, Integer::sum);
        }
        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


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

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

    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++];
    }

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

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

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 63168
a,b = map(int,input().split())
s = input()
L = [i for i in range(10)]
ans = "Yes"
for i in range(a):
  if s[i]=="-" or not int(s[i]) in L:
    ans = "No"
if s[a] != "-":
  ans = "No"
for i in range(a+1,a+b+1):
    if s[i]=="-" or not int(s[i]) in L:
      ans = "No"
print(ans)

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

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

int main() {
    int K;
    cin >> K;

    ll ans = 0LL;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                int res = gcd(gcd(a, b), c);
                ans += (ll)res;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    for i in 0..s.len() {
        if (i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'){
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String re ="";
		for(int i = line.length() ; i > 0;i--){
			re += line.charAt(i-1);
		}
		System.out.println(re);

	}

}

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

int main() {
    int N, D; cin >> N >> D;
    vector<vector<int>> x(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> x.at(i).at(j);
        }
    }
    map<int, bool> key;
    for (int i = 1; i < 127; i++) {
        key[i * i] = true;
    }
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        for (int k = i+1; k < N; k++) {
            int sum = 0;
            for (int j = 0; j < D; j++) {
                sum += (x.at(i).at(j) - x.at(k).at(j)) * (x.at(i).at(j) - x.at(k).at(j));
            }
            if (key[sum]) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int ans=0;
  while (A%2==0 && B%2==0 && C%2==0){
    int A1=B/2+C/2;
    int B1=A/2+C/2;
    int C1=A/2+B/2;
    ans++;
    A=A1;
    B=B1;
    C=C1;
    if(ans>10000){
      ans=-1;
      break;
    }
  }
  cout<<ans<<endl;
}
    
    

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    deque<int> ans;
    REP(i, N) {
        if (i % 2 == 0) {
            ans.push_back(a[i]);
        } else {
            ans.push_front(a[i]);
        }
    }
    if (N % 2 == 0) {
        REP(i, N) { cout << ans[i] << " "; }
    } else {
        RREP(i, N - 1) { cout << ans[i] << " "; }
    }
    cout << endl;

    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<int, int, int> tint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.second < arg2.second; }
bool compTuple(const tint& arg1, const tint& arg2) { return get<1>(arg1) < get<1>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

void add(vector<int>& dat,int i,int x,int n){
    for(int ix=i;ix<=n;ix+=ix&-ix) dat[ix]+=x;
}
int sum(vector<int>& dat,int i){
    int res=0;
    for(int ix=i;ix>=1;ix-=ix&-ix) res+=dat[ix];
    return res;
}
int rangesum(vector<int>& dat,int l,int r){//[l,r]
    return sum(dat, r)-sum(dat, l-1);
}

int main(void) {
    int n, q;
    cin >> n >> q;
    vector<int> c(n+1);
    vector<tint> lrd(q+1);
    for(int in=1;in<=n;++in) {
        cin >> c[in];
    }
    int l, r;
    for(int iq=1;iq<=q;++iq) {
        cin >> l >> r;
        lrd[iq] = make_tuple(l, r, iq);
    }
    sort(lrd.begin(), lrd.end(), compTuple);

    vector<int> rightmost(n+1, -1);
    vector<int> fwtree(n+1, 0);
    vector<pint> ans;
    int now = 1;
    for(int iq=1;iq<=q;++iq) {
        int nowl, nowr, nowd;
        nowl = get<0>(lrd[iq]);
        nowr = get<1>(lrd[iq]);
        nowd = get<2>(lrd[iq]);
        for(int inow=now;inow<=nowr;++inow) {
            if(rightmost[c[inow]]!=-1) {
                add(fwtree, rightmost[c[inow]], -1, n);
            }
            add(fwtree, inow, 1, n);
            rightmost[c[inow]] = inow;
        }
        now = nowr;
        ans.push_back(make_pair(nowd, rangesum(fwtree, nowl, nowr)));
    }

    sort(ans.begin(), ans.end());
    for(auto ians:ans) cout << ians.second << endl;
    return 0;
}


Measured memory_bytes: 19516
#include <bits/stdc++.h>
using namespace std;
int main() {
for (int i = 0; i < 114514; i++){
int a, b; 
string op; 
cin >> a >> op >> b; 
if(op == "+") cout << a + b << endl;  
if(op == "-") cout << a - b << endl;
if(op == "*") cout << a * b << endl;
if(op == "/") cout << a / b << endl;
if(op == "?") break; 
}
}


Measured memory_bytes: 3152
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from math import factorial
n, m = map(int, input().split())
if n < 2:
    if m < 2:
        print(0)
    else:
        ans = factorial(m) / factorial(2) / factorial(m - 2)
        print(int(ans))
else:
    if m < 2:
        ans = factorial(n) / factorial(2) / factorial(n - 2)
        print(int(ans))
    else:
        ans = factorial(n) / factorial(2) / factorial(n - 2) + factorial(m) / factorial(2) / factorial(m - 2)
        print(int(ans))

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

#define endl '\n'

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	string s,s1,s2,s3;
	ll k,c1,c2,c3,ans;
	cin>>s>>k;
	s1=s;
	c1=0;
	for(int i=1;i<s1.size();){
		if(s1[i]==s1[i-1]){
			s1[i]='*';
			c1++;
			i+=2;
		}
		else i++;
	}
	if(k>1){
		c2=0;
		s2=s1+s;
		for(int i=s1.size();i<s2.size();){
			if(s2[i]==s2[i-1]){
				s2[i]='*';
				c2++;
				i+=2;
			}
			else i++;
		}
		if(k>2){
			c3=0;
			s3=s2+s;
			for(int i=s2.size();i<s3.size();){
				if(s3[i]==s3[i-1]){
					s3[i]='*';
					c3++;
					i+=2;
				}
				else i++;
			}
			if(c1==c2) ans=k*c1;
			else if(c1==c3){
				ans=k/2*(c1+c2);
				if(k%2) ans+=c1;
			}
			else ans=(k-1)*c2+c1;
		}
		else ans=c1+c2;
	}
	else ans=c1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  ll s_ct;
  ll e_ct;

  {
    ll d = 1 + 8 * N;
    ll d_root = sqrt(d);
    unless(d_root * d_root == d) drop("No");

    // d_root は必ず奇数
    s_ct = (1 + d_root) / 2;
    e_ct = s_ct - 1;
  }

  VVL res(s_ct, VL());

  ll next_num = 1;

  rep(i, s_ct) {
    repf(j, i + 1, s_ct) {
      res[i].push_back(next_num);
      res[j].push_back(next_num);
      next_num++;
    }
  }

  cout << "Yes" << endl;
  cout << s_ct << endl;

  rep(i, s_ct) {
    cout << e_ct << " ";
    print_ints(res[i]);
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
#include <numeric>
using namespace std;
template< class RandomIter >
void quick_sort(RandomIter first, RandomIter last)
{
  if (last - first <= 1) { return; }
  RandomIter i = first, j = last - 1;
  for (RandomIter pivot = first;; ++i, --j)
  {
    while (*i < *pivot) { ++i; }
    while (*pivot < *j) { --j; }
    if (i >= j) { break; }
    std::iter_swap(i, j);
  }
  quick_sort(first, i);
  quick_sort(j + 1, last);
}

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

    priority_queue <long long> A;

    for(int  i = 0 ; i < N ; i++){
        long long a;
        cin >> a;
        A.push(a);
    }

    for(int i = 0; i < M ;i++){
        long long at = A.top();
        at /= 2;
        A.pop();
        A.push(at);
    }

    long long sum = 0;
    // for(int i = 0; i < A.size() ; i++){
    while(!A.empty()){
        sum += A.top();
        A.pop();
    }

    cout  << sum << endl;
}

Measured memory_bytes: 1400
from copy import deepcopy

H, W, K = map(int, input().split())
c = [input().rstrip() for _ in range(H)]

ans = 0
for i in range(2**H):
    for j in range(2**W):
        c2 = deepcopy(c)
        for k in range(H):
            c2[k] = list(c2[k])

        for k in range(i):
            if (i >> k) % 2:
                for l in range(W):
                    c2[k][l] = '.'

        for k in range(j):
            if (j >> k) % 2:
                for l in range(H):
                    c2[l][k] = '.'

        black = 0
        for k in range(H):
            for l in range(W):
                if c2[k][l] == '#':
                    black += 1

        if black == K:
            ans += 1

print(ans)

Measured memory_bytes: 71764
n = int(input())
a = list(map(int, input().split()))
def f():
    b = [0] * n
    for i in range(n-1, -1, -1):
        b[i] = a[i] ^ (sum(b[i::i+1]) & 1)
    return b
res = [i+1 for i, x in enumerate(f()) if x > 0]
print(len(res))
print(' '.join(map(str, res)))


Measured memory_bytes: 18872
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

    var a = input[0];
   
 // SUN,MON,TUE,WED,THU,FRI,SAT
    if (a == 'SUN'){console.log('7');}
    else if(a == 'MON'){console.log('6');}
    else if(a == 'TUE'){console.log('5');}
    else if(a =='WED'){console.log('4');}
    else if(a == 'THU'){console.log('3');}
    else if (a == 'FRI'){console.log('2');}
    else if (a == 'SAT'){console.log('1');}
    
	
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import itertools
import math

n = int(input())
roots = [list(map(int, input().split())) for _ in range(n)]

distances = []
for root in itertools.permutations(range(1, n+1)):
    total = 0
    for i, j in enumerate(root):
        nxt_idx = (i+1) % len(root)
        nxt_root = root[nxt_idx]
        if nxt_idx == 0:
            break

        x1, y1 = roots[j-1]
        x2, y2 = roots[nxt_root-1]

        tmp = (x1 - x2)**2 + (y1-y2)**2
        distance = math.sqrt(tmp)
        total += distance

    distances.append(total)

ave = sum(distances) / len(distances)
print(ave)


Measured memory_bytes: 4400
import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int,input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
#x = [int(input()) for i in range(q)]

ans = 10**100

for i in range(q):
    x = int(input())
    ans = 10**100
    s_idx = bisect.bisect_left(s,x)
    t_idx = bisect.bisect_left(t,x)
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(ans,abs(x - s[min(s_idx+j,a-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]),abs(x - t[min(t_idx+k,b-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))
            
    print(ans)

Measured memory_bytes: 12216
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
ll l[200001],dpr[200001],dpl[200001];
void solve()
{
	int n;
	cin>>n;
	ll d;
	cin>>d;
	ll ret=0;
	for (int i=0;i<n;i++) cin>>l[i],ret+=l[i];
	ret+=(n-1)*d;
	dpr[0]=l[0];
	for (int i=1;i<n;i++) dpr[i]=min(l[i],dpr[i-1]+d);
	dpl[n-1]=l[n-1];
	for (int i=n-2;i>=0;i--) dpl[i]=min(l[i],dpl[i+1]+d);
	for (int i=1;i<n-1;i++) ret+=min(dpl[i],dpr[i]);
	cout<<ret;
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
	int n, h, m = 0;
	cin >> n;

	bool res = true;
	for(int i = 0; i < n; i++) {
		cin >> h;
		if(m - h >= 2) {
			res = false;
			break;
		}
		m = max(m, h);
	}

	if(res == true) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int a1 = a;
    if(a1 >= k){
        cout << k;
        return 0;
    }
    int r = k - a1;
    if(b >= r){
        cout << a1 << "\n";
        return 0;
    }
    int rr = r-b;
    cout << a1 - rr; 
    return 0;
}
 

Measured memory_bytes: 3612
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan 16 16:24:03 2019
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
		arr[i]--
	}
	visited := make([]bool, N)

	next := 0
	ans := 0
	for next != 1 && !visited[next] {
		visited[next] = true
		next = arr[next]
		ans++
	}

	if next != 1 {
		fmt.Println("-1")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 5504
from itertools import product
from heapq import nlargest

N,M = map(int,input().split())
X = tuple(tuple(map(int,input().split())) for _ in range(N))

print(max(sum(nlargest(M, (a*x+b*y+c*z for x,y,z in X))) for a,b,c in product((-1,1), repeat=3)))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int a, b;
    cin>>a>>b;
    int n=1;
    int ans=0;
    while(n<b){
        n--;
        n+=a;
        ans++;
    }
    cout<<ans<<"\n";



    return 0;
}

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

    int a;
    cin >> a;

    cout << setprecision(7);
    if(a%2 == 0){
        cout << 0.5 << endl;
        return 0;
    }
    else{
        cout << (double) ((double)((a+1)/2)/a) << endl;
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n+1], x;
  for ( int i = 1; i <= n; i++){
    cin >> x;
    a[x] = i;
  }

  for ( int i = 1; i <= n; i++){
    if ( i > 1) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;

int main() {
  double v;
  while(cin >>v){
    double hight= 4.9*(v/9.8)*(v/9.8);
    int kai= ceil((hight +5)/5);
    cout << kai <<endl;
  }
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int plan1, plan2;
  plan1 = N * A;
  plan2 = B;
  
  if(plan1 < plan2) {
  	cout << plan1 << endl;
  }
  else {
  	cout << plan2 << endl;
  }

}

Measured memory_bytes: 3516
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

map<ll, ll> factor(ll n, const std::vector<ll> &min_factor)
{
  map<ll, ll> mp;
  while (n > 1)
  {
    mp[min_factor[n]]++;
    n /= min_factor[n];
  }
  return mp;
}

std::vector<ll> sieve(ll n)
{
  std::vector<ll> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (ll i = 2; i * i < n; ++i)
  {
    if (res[i] < i)
      continue;
    for (ll j = i * i; j < n; j += i)
      if (res[j] == j)
        res[j] = i;
  }
  return res;
}

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

  vector<ll> res = sieve(N + 1);
  ll ans = 0;
  for (ll i = 1; i <= N; ++i)
  {
    map<ll, ll> t = factor(i, res);
    ll s = 1;
    for (auto &e : t)
      s *= e.second + 1;
    ans += i * s;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(void) {
    int n;
    long int sum = 0;
    cin >> n;


    for(int i = 1; i <= n; i++){
        // cout << "a i = " << i << endl;
        // cout << "a sum = " << sum << endl;
        if(i % 15 == 0){
            //cout << "FizzBuzz" << endl;
        }
        else if(i % 3 == 0){
            //cout << "Fizz" << endl;
        }
        else if(i % 5 == 0){
            //cout << "Buzz" << endl;
        }
        else{
            sum = sum + i;
            // cout << "i = " << i << endl;
            // cout << "sum = " << sum << endl;
        }
    }

    cout << sum << endl;
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明


// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }


// ll my_gcd(ll a, ll b){
// 	return (b==0) ? a : my_gcd(b, a%b);
// }


//  ll my_lcm(ll a, ll b){
//  	return a*b / my_gcd(a,b);
//  }


// ll factorial(ll a){
// 	ll ans = 1;
// 	for(ll i=a; i>0; i--){
// 		ans *= i;
// 	}
// 	return ans;
// }

int main(int argc, char *argv[]){
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<3; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }

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


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

using namespace std;

int main(){

    string S;
    cin >> S;

    if(stoi(S.substr(0,2))>12&&stoi(S.substr(2,2))>12){
        cout<<"NA"<<endl;
    }else if(stoi(S.substr(0,2))==0&&stoi(S.substr(2,2))==0){
        cout<<"NA"<<endl;
    }else if(stoi(S.substr(0,2))>12&&stoi(S.substr(2,2))==0){
        cout<<"NA"<<endl;
    }else if(stoi(S.substr(0,2))<=0&&stoi(S.substr(2,2))>12){
        cout<<"NA"<<endl;
    }else if(stoi(S.substr(0,2))==0&&stoi(S.substr(2,2))<=12){
        cout<<"YYMM"<<endl;
    }else if(stoi(S.substr(0,2))<=12&&stoi(S.substr(2,2))==0){
        cout<<"MMYY"<<endl;
    }else if(stoi(S.substr(0,2))==0&&stoi(S.substr(2,2))<=12){
        cout<<"YYMM"<<endl;
    }else if(stoi(S.substr(0,2))<=12&&stoi(S.substr(2,2))<=12){
        cout<<"AMBIGUOUS"<<endl;
    }else if(stoi(S.substr(0,2))>12&&stoi(S.substr(2,2))<=12){
        cout<<"YYMM"<<endl;
    }else if(stoi(S.substr(0,2))<=12&&stoi(S.substr(2,2))>12){
        cout<<"MMYY"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;

        try{
        while(!(line = reader.readLine()).equals("-")){

        int m =Integer.parseInt(reader.readLine());

        for(int i=0;i<m;i++){
            int h =Integer.parseInt(reader.readLine());
            line = line.substring(h,line.length()) + line.substring(0,h);
        }
        System.out.println(line);
        }
        } catch (IOException e){
            System.out.println(e);
        }
        
    }
    
    
}


Measured memory_bytes: 24388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var listE = new List<int>();
            var listW = new List<int>();

            var ans = new List<int>();

            // 累積和
            for (int i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    if (s[i] == 'E')
                    {
                        listE.Add(1);
                        listW.Add(0);
                    }
                    else
                    {
                        listE.Add(0);
                        listW.Add(1);
                    }
                    continue;
                }

                if (s[i] == 'E')
                {
                    listE.Add(listE[i - 1] + 1);
                    listW.Add(listW[i - 1]);
                }
                else
                {
                    listE.Add(listE[i - 1]);
                    listW.Add(listW[i - 1] + 1);
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    // 左の累積和＋右の累積和
                    ans.Add(0 + listE[n - 1] - listE[i]);
                    continue;
                }
                // 左の累積和＋右の累積和
                ans.Add(listW[i - 1] + listE[n - 1] - listE[i]);
            }

            Console.WriteLine(ans.Min());
        }
    }
}

Measured memory_bytes: 24928
from itertools import islice

def make_seq():
    n, m, l = list(map(int, input().split()))

    m1 = [list(map(int, input().split())) for _ in range(n)]
    m2 = [list(map(int, input().split())) for _ in range(m)]

    def g():
        for r1 in m1:
            for r2 in zip(*m2):
                yield str(sum(i*j for i, j in zip(r1, r2)))

    return (n, l, list(g()))

n, l, lst = make_seq()
for i in range(n):
    print(" ".join(islice(lst, i*l, (i+1)*l)))

Measured memory_bytes: 9144
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	sc.Split(bufio.ScanWords)
	S, T := nextString(), nextString()

	fmt.Println(T + S)
}


Measured memory_bytes: 640
// Problem : E - Or Plus Max
// Contest : AtCoder Regular Contest 100
// URL : https://atcoder.jp/contests/arc100/tasks/arc100_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7;

struct pp {
	int mx, id;
};

struct mm {
	pp mx1, mx2;
} dp[N];

int n, ans = 0, a[N];

void pass(pp &mx1, pp &mx2, pp x) {
	if (mx1.mx == x.mx) {
		if (mx2.mx < x.mx && mx1.id != x.id) {
			mx2 = x;
		}
	} else if (mx1.mx < x.mx) {
		mx2 = mx1;
		mx1 = x;
	} else if (mx2.mx < x.mx) {
		mx2 = x;
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < 1 << n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 1 << n; i++) {
		dp[i].mx1 = {a[i], 1 << i};
	}
	for (int i = 0; i < n; i++) {
		for (int mask = 0; mask < 1 << n; mask++) {
			if (mask & (1 << i)) {
				pass(dp[mask].mx1, dp[mask].mx2, dp[mask ^ (1 << i)].mx1);
				pass(dp[mask].mx1, dp[mask].mx2, dp[mask ^ (1 << i)].mx1);
			}
		}
	}
	ans = dp[0].mx1.mx + dp[0].mx2.mx;
	for (int k = 1; k < 1 << n; k++) {
		ans = max(ans, dp[k].mx1.mx + dp[k].mx2.mx);
		cout << ans << '\n';
	}
}


Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
using namespace std;

int main(){
    int n;
    cin >> n;
    string ans = "No";
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j == n){
                ans = "Yes";
            }
        }
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int A[1000000],n;
int Search(int key){
	int left =0;
	int right = n;
	int mid;
	while(left < right){
		mid=(left+right)/2;
		if(key==A[mid])return 1;
		if(key > A[mid])left = mid+1;
		else if(key<A[mid])right =mid;
	}	
	return 0;
}

int main(){
	int i,q,k,sum=0;
	
	cin >> n;
	for(int i=0; i<n; i++)cin >> A[i];
	
	cin >> q;
	for(int i=0; i<q; i++){
		cin >> k;
		if(Search(k))sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3496
n=int(input())
l=[];cnt=0;a1=0;a2=0;a3=0
l= list(map(int,input().strip().split()))[:n]
for i in range(n-2):
    mid=0
    a1=l[i]
    a2=l[i+1]
    a3=l[i+2]
    if a2 is not max(a1,a2,a3) and a2 is not min(a1,a2,a3):
        cnt+=1
print(cnt)











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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  for (ll i = 0; i < n - 2; i++)
  {
    string ss = s.substr(i, 3);
    if (ss == "ABC")
      ans++;
  }
  cout << ans << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256