akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.{readLine, readInt}

object Main extends App {

  case class Card(suit: Char, num: Int)

  val N = readInt
  val cards = readLine.split(" ").map(e => Card(e.charAt(0), e.charAt(1).asDigit))
  val cards1 = cards.clone()
  val cards2 = cards.clone()

  val bubbleSorted = bubbleSort(cards1, N)
  val selectionSorted = selectionSort(cards2, N)

  println(bubbleSorted.map(e => e.suit.toString + e.num).mkString(" "))
  println("Stable")

  println(selectionSorted.map(e => e.suit.toString + e.num).mkString(" "))
  println(if (isStable(bubbleSorted, selectionSorted, N)) "Stable" else "Not stable")


  def swap(arr: Array[Card], n: Int, m: Int): Unit = {
    val tmp = arr(n)
    arr(n) = arr(m)
    arr(m) = tmp
  }

  def isStable(arr1: Array[Card], arr2: Array[Card], n: Int): Boolean = {
    (0 until n).foreach {
      i => if (arr1(i).suit != arr2(i).suit) return false
    }
    true
  }

  def bubbleSort(arr: Array[Card], n: Int): Array[Card] = {
    (0 until n).foreach { i =>
      (n - 1 until i by -1).foreach { j =>
        if (arr(j).num < arr(j - 1).num) {
          swap(arr, j, j - 1)
        }
      }
    }
    arr
  }

  def selectionSort(arr: Array[Card], n: Int): Array[Card] = {
    (0 until n).foreach { i =>
      var minj = i
      (i until n).foreach { j =>
        minj = if (arr(j).num < arr(minj).num) j else minj
      }
      swap(arr, minj, i)
    }
    arr
  }
}



Measured memory_bytes: 44136
#include <iostream>
using namespace std;
int main(void){
    int n; cin >> n;
    int ichi = n % 10;
    int ju = (n % 100 - ichi) / 10;
    int hyaku = (n - ju * 10 - ichi) / 100;
    int judge = hyaku * 100 + hyaku * 10 + hyaku;
    int ans = n;
    if(ichi != ju || ju != hyaku || hyaku != ichi){
        if(judge < n){
            ans = (hyaku + 1) * 100 + (hyaku + 1) * 10 + (hyaku + 1);
        }else{
            ans = judge;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int solve(){
  int n,w,h;
  pair<int,int> piece[SIZE];
  int p_size = 0;
  
  scanf("%d%d%d",&n,&w,&h);
  
  if(w == 0) return false;
  
  piece[p_size++] = {w,h};
  
  for(int i=0;i<n;i++){
    int p,s, p_in;
    
    scanf("%d%d",&p_in,&s);

    for(int j=0;;j++){
      if(piece[j].first > 0){
        p_in--;
        if(p_in == 0){
          p = j;
          break;
        }
      }
    }
    
    int w = piece[p].first;
    int h = piece[p].second;
    piece[p] = {-1,-1};
    
    int w1, h1, w2, h2;
    
    if(s%(w+h) < w){
      w1 = s%(w+h);
      w2 = w - s%(w+h);
      h1 = h2 = h;
    }else{
      s -= w;
      h1 = s%(w+h);
      h2 = h - s%(w+h);
      w1 = w2 = w;
    }

    if(w1*h1 > w2*h2){
      swap(w1,w2);
      swap(h1,h2);
    }
    
    piece[p_size++] = {w1,h1};
    piece[p_size++] = {w2,h2};
  }

  vector<int> vec;
  
  for(int i=0;i<p_size;i++){
    if(piece[i].first != -1){
      vec.push_back(piece[i].first*piece[i].second);
    }
  }

  sort(vec.begin(),vec.end());

  for(int i=0;i<vec.size();i++){
    printf("%d%c",vec[i]," \n"[i+1==vec.size()]);
  }
  
  return true;
}

int main(){

  while(solve());

}

Measured memory_bytes: 4028
/* Author - Ankur Kumar Singh 
    	IDE :- Offine Linux
     ---------------------------------*/
    #include <bits/stdc++.h>
    using namespace std;
    /* variable type :- */
    	/* variable type :- */
    	# define ll  long long int
    	# define ld  long double
    	# define I ll
    	# define mod 1000000007
    /* map */
    	# define abc  pair< ll, ll>
    	map < pair < abc,abc > ,  ll > pqr;
    	map <  pair <  ll, ll > , ll > xyz;	
    /* vector */
    	# define pb push_back
    	# define pp pop_back
    	# define ff first
    	# define ss second
    	# define mp make_pair
    	# define ac accumulate
    	vector<pair<ll,string>>a1;
    	vector<pair<ll,string>>a2;
    	vector<pair<ll,string>>a3;
    	vector<pair<ll,string>>a4;
    	vector<pair<ll,string>>a5;
    	vector<pair<ll,string>>a6;
    	vector<pair<ll,string>>a7;
    	vector<pair<pair<ll,ll>,ll>>b;
    	ll cnt;
    	ll X[121],Y[121];
     
  
    int main()
    {
    	ios_base::sync_with_stdio(false); 
        	cin.tie(NULL); 
        string n;
	cin>>n;
	ll r=int(n[0])-48;
	ll w=r*10+r;
	ll k=(int(n[1])-48)*10+n[2]-48;
	//cout<<w<<" "<<k<<" "<<r<<endl;
	if(w>=k)
	{
	    cout<<r<<r<<r;
	    
	}
	else
	{
	    cout<<r+1<<r+1<<r+1;
	    
	}
    	
    }

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int x=sc.nextInt()*4;
		int y=sc.nextInt()*2;
		
		int z=Math.min(sc.nextInt(),Math.min(x, y));
		int w=Math.min(sc.nextInt(),z*2);
		
		
		int n=sc.nextInt();
		pw.println(1L*(n/2)*w+(n%2)*z);
		
		pw.flush();
		pw.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a == b)cout << a + b << endl;
	else cout << max(a, b) * 2 - 1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin>>s;
	bool f=true;
	For(i,0,sz(s)-1){
		if(i%2==0 && s[i]=='L'){
			f=false; break;
		}
		else if(i%2==1 && s[i]=='R'){
			f=false; break;
		}
	}
	if(f) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}





























Measured memory_bytes: 256
k=int(input())
a,b= map(int,input().split(' '))
c=True
i=1
while c==True:
    if (a<=k*i) and (k*i<=b) :
         print('OK')
         break
    if k*i>b :
         print("NG")
         break
    i=i+1
     

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a, b, n;
		int sum;

		while (sc.hasNext()) {
			a = sc.nextInt();
			b = sc.nextInt();
			n = sc.nextInt();
			a %= b;
			a *= 10;
			sum = 0;
			for (int i = 0; i < n; i++) {
				sum += a / b;
				a %= b;
				a *= 10;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+10;
const ll MOD=1e9+7;
ll n,k;
ll ans[maxN];
ll res=0LL;
ll fast_mi(ll a,ll n)
{
	ll ans=1;
	while(n){
		if(n%2==1) ans=(ans*a)%MOD;
		a=(a*a)%MOD;
		n=n/2;
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(ll x=k;x>=1LL;x--)
	{
		//ll multi_num=k/x;
		 ans[x]=fast_mi(k/x,n);
		for(ll i=2*x;i<=k;i+=x)
		{
			ans[x]=(ans[x]-ans[i]+MOD)%MOD;  //防止为负数 
		}
		res=(res+ans[x]*x%MOD)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4308
n = int(input())
a = list(map(int, input().split(" ")))
if len(list(filter(lambda x: x < 0, a))) % 2 == 0:
    print(sum(list(map(abs, a))))
else:
    a = list(map(abs, a))
    print(sum(a) - min(a)*2)

Measured memory_bytes: 14412
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main(){
    long long int n;
    long long int a, b;
    cin >> n;
    long long int i, j;
    long long int count = 0;
    map<long long int, long long int> s;
    b = 0;
    s[0] = 1;
    
    j = 0;
    for(i = 0; i < n; i++){
        cin >> a;
        b += a;
        count += s[b]++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 12800
/*
 *    author:  Gary Shih
 *    created: 2020-05-06 16:49:47
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

// Convex Hull {{{
class ConvexHull {
 public:
  deque<pair<long long, long long>> dq;

  // Lower: m needs to be decreasing
  // Upper: m needs to be increasing
  void Insert(long long m, long long b) {
    while ((int)dq.size() > 1) {
      auto& l1 = dq[dq.size() - 1];
      auto& l2 = dq[dq.size() - 2];
      if ((b - l2.second) * (l2.first - l1.first) <
          (l1.second - l2.second) * (l2.first - m))
        dq.pop_back();
      else
        break;
    }
    dq.emplace_back(m, b);
  }
  // x needs to be increasing
  long long Query(long long x) {
    assert(dq.empty() == false);
    while ((int)dq.size() > 1) {
      auto& l1 = dq[0];
      auto& l2 = dq[1];
      if ((l2.second - l1.second) < (l1.first - l2.first) * x)
        dq.pop_front();
      else
        break;
    }
    return dq.front().first * x + dq.front().second;
  }
  bool empty() { return dq.empty(); }
};
// }}}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  long long n, c;
  cin >> n >> c;
  vector<long long> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  ConvexHull hull;
  vector<long long> dp(n);
  hull.Insert(-2 * h[0], dp[0] + h[0] * h[0]);
  for (int i = 1; i < n; ++i) {
    long long value = hull.Query(h[i]);
    dp[i] = value + h[i] * h[i] + c;
    hull.Insert(-2 * h[i], dp[i] + h[i] * h[i]);
  }
  cout << dp.back() << '\n';
}


Measured memory_bytes: 5632
#include <stdio.h>

int main(){
  int M[100][100];
  int i, j, n, u, k, v;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j]=0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d", &v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j) printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define INF (1<<30)
using ll = long long;
using namespace std;
 
int main(){
	int N;
	string S;
	cin >> N >> S;
	int l[N], r[N];
	l[0] = 0;
	r[N-1] = 0;
	for(int i=1; i<N; ++i){
		l[i] = l[i-1];
		if( S[i-1] == 'W' ){
			l[i]++;
		}
	}
	for(int i=N-2; 0<=i; --i){
		r[i] = r[i+1];
		if( S[i+1] == 'E' ){
			r[i]++;
		}
	}
	int min = INF;
	for(int i=0; i<N; ++i){
		int sum = l[i] + r[i];
		if( min > sum ){
			min = sum;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3076
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	vector<int> ans(n+1,0);
	rep(i,101){
	    rep(j,101){
	        rep(k,101){
	            int x=i+1;
	            int y=j+1;
	            int z=k+1;
	            int sum=x*x+y*y+z*z+x*y+y*z+z*x;
	            if(sum<=n)ans[sum]++;
	        }
	    }
	}
	rep(i,n){
	    cout<<ans[i+1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#define N 100000

int main(void){
  int prime[N],i,j,n;

  for(i=2;i<N;i++)
    prime[i]=0;

  prime[0]=1;
  prime[1]=1;

  for(i=2;i*i<=N;i++){
    if(prime[i]==0){
      for(j=2*i;j<N;j+=i){
	prime[j]=1;
      }
    }
  }

  while(scanf("%d",&n),n){
    int count=0;
    for(i=2;i<=n/2;i++){
      if(prime[i]==0 && prime[n-i]==0)count++;
    }
    printf("%d\n",count);
  }
  return 0;
}

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

int main(){
	int n;
	while(cin >> n,n){
		int s[12],cnt[101];
		for(int i = 0;i < n;i++) cin >> s[i];
		int num;
		for(num = 0;;num++){
			bool flag = true;
			for(int i = 0;i <= 100;i++) cnt[i] = 0;
			for(int i = 0;i < n;i++) cnt[s[i]]++;
			for(int i = 0;i <= 100;i++){
				if(cnt[i] != 0 && cnt[i] != i) flag = false;
			}
			if(flag) break;
			for(int i = 0;i < n;i++) s[i] = cnt[s[i]];
		}
		cout << num << endl;
		for(int i = 0;i < n - 1;i++) cout << s[i] << " ";
		cout << s[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
n = int(input())
nums = [int(input()) for _ in range(n)]

temp_min = nums[0]
max_profit = nums[1] - nums[0]

for num in nums[1:]:
    max_profit = max(max_profit, num-temp_min)
    temp_min = min(temp_min, num)

print(max_profit)



Measured memory_bytes: 15092
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int h, w;
  cin >> h >> w;
  char c[410];
  rep(i, h * w) cin >> c[i];
  int d[410][410];
  rep(i, 410) rep(j, 410)
  {
    d[i][j] = (i == j ? 0 : INF);
  }
  rep(i, h * w)
  {
    if (i + w < h * w && c[i] == '.' && c[i + w] == '.')
      d[i][i + w] = d[i + w][i] = 1;
    if (i + 1 < h * w && i % w != w - 1 && c[i] == '.' && c[i + 1] == '.')
      d[i][i + 1] = d[i + 1][i] = 1;
  }
  rep(k, h * w) rep(i, h * w) rep(j, h * w)
  {
    if (c[i] == '#' || c[j] == '#' || c[k] == '#')
      continue;
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
  int Max = 0;
  rep(i, h * w) rep(j, h * w)
  {
    if (c[i] == '#' || c[j] == '#')
      continue;
    Max = max(Max, d[i][j]);
  }

  cout << Max << endl;
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
int n;cin>>n;
vector<long long> A(n);
rep(i,n){
	cin>>A[i];
  }
vector<long long> B(n+1);
B[0]=0;
rep(i,n){
	B[i+1]=B[i]+A[i];
//	ch(B[i+1],"B[i+1");che(i+1,"i+1");
  }
  long long ans = 0;
  long long count =1;
  SORT(B);
  rep(i,n){
	if(B[i]==B[i+1]){
		count++;
		if(i==n-1){
			ans+=(count*(count-1));
		  }
	  }
	else if(B[i]!=B[i+1]){
			ans+=(count*(count-1));
			count = 1;
	  }
  }
	cout <<ans/2<<endl;
}


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

int main(){
	int n,m;scanf("%d%d",&n,&m);
	int a=1;
	rep(i,m)a*=2;
	cout<<a*(m*1900+(n-m)*100)<<endl;
}

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

void trial_division_sqrt(long long n, vector<long long> &v) {
    long long sqrt_n = (long long)sqrt(n);
    for (long long i = 2; i <= sqrt_n + 1; i++) {
        if (n % i == 0) {
            v.emplace_back(i);
        }
        while (n % i == 0) {
            n /= i;
        }
    }
    if (n > 1) {
        v.emplace_back(n);
    }
}

int main(int argc, char const *argv[]) {
    long long a, b;
    cin >> a >> b;

    vector<long long> va, vb;

    trial_division_sqrt(a, va);
    trial_division_sqrt(b, vb);

    vector<long long> ab_inter;
    set_intersection(va.begin(), va.end(), vb.begin(), vb.end(),
                     inserter(ab_inter, ab_inter.end()));

    cout << ab_inter.size() + 1 << endl;

    return 0;
}


Measured memory_bytes: 384
package main


import (
  "fmt"
)

func main(){
  var a [3][3]int
  var b [3][3]bool
  var N int
  
  for i := 0; i < 3; i++ {
  	fmt.Scanf("%d %d %d\n", &a[i][0], &a[i][1], &a[i][2])
  }
  
  fmt.Scanf("%d\n", &N)
  
  for i := 0; i < N; i++ {
    var input int
    fmt.Scanf("%d\n", &input)
    for j := 0; j < 3; j++ {
      for k := 0; k < 3; k++ {
        if a[j][k] == input {
          b[j][k] = true
        }
      }
    }
  }
  var ret bool = false
  for i := 0; i < 3; i++ {
    if b[i][0] && b[i][1] && b[i][2]{
      ret = true
      break
    }
    if b[0][i] && b[1][i] && b[2][i] {
      ret = true
      break
    }
  }
  if b[0][0] && b[1][1] && b[2][2] {
    ret = true
  }
  if b[0][2] && b[1][1] && b[2][0] {
    ret = true
  }
  if ret {
	  fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s;cin>>s;
  for(i=0;i<3;i++){
    result+=s[i]-'0';
  }
  cout<<result<<endl;


  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int A[N];
    double ans=0;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<N;i++){
        ans+=1/(double)A[i];
    }
    ans=(double)1/ans;
    printf("%lf\n",ans);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        s ^= a[i];
    }
    for (int i = 0; i < N; i++) {
        cout << (s ^ a[i]) << " ";
    }
    return 0;
}


Measured memory_bytes: 4008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
        List<Integer> list = new ArrayList<>();   
        
        list.add(sc.nextInt());
        
        int x=0;
        
        while(true){
            
            list.add(sc.nextInt());
            x++;
            
            if(x == list.get(0)){
                break;
            }
            
            
        }
            
        
        
        for(int i=list.size()-1; i>0; i--){
            System.out.print(list.get(i));
            if(i != 1) System.out.print(" ");
                            
        }
           System.out.println("");
        }           
    }



        
    

       

   




Measured memory_bytes: 26296
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s;
  cin >>s;
  int S=s.size();
  int count =0;
  
  rep(i,S/2){
    if(s[i]!=s[S-1-i]) count++;
  }
  cout <<count<<endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	v := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range v {
		sc.Scan()
		v[i], _ = strconv.Atoi(sc.Text())
	}

	ans := 0
	for i := 0; i <= min(k, n); i++ {
		for j := 0; j <= min(k, n); j++ {
			if i+j > min(k, n) {
				continue
			}
			rem := k - i - j
			a := make([]int, 0, i+j)
			for i2 := 0; i2 < i; i2++ {
				a = append(a, v[i2])
			}
			for j2 := 0; j2 < j; j2++ {
				a = append(a, v[n-1-j2])
			}
			sort.Ints(a)
			s := 0
			for _, e := range a {
				if e >= 0 {
					s += e
				} else {
					if rem > 0 {
						rem--
					} else {
						s += e
					}
				}
			}
			ans = max(ans, s)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

  int ans = x;
  for(int i = 0; i < n; i++){
    int y = 1;
    while(y <= d){
      ++ans;
      y += a[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 632
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

int n, t;
int cnt;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t;
        if (i % 2 == 1 && t % 2 == 1) {
            cnt++;
        }
    }
    cout << cnt;

    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static List<int> aDivisors;
        static List<int> bDivisors;
        static List<int> commonDivisors;

        static void Main(string[] args)
        {
            //[summary]B - K-th Common Divisor
            var line = ReadLine();
            int a = line[0];
            int b = line[1];
            int k = line[2];

            aDivisors = GetDivisors(a).ToList();
            bDivisors = GetDivisors(b).ToList();

            //公約数を大きい順にソート
            commonDivisors = GetCommonDivisors().OrderByDescending(x => x).ToList();

            //K番目に大きい公約数を出力
            Console.WriteLine(commonDivisors[k - 1]);
        }

        static IEnumerable<int> GetCommonDivisors()
        {
            foreach(var d in aDivisors)
            {
                if (bDivisors.Contains(d))
                {
                    yield return d;
                }
            }
        }

        static IEnumerable<int> GetDivisors(int num)
        {
            for(int i = 1; i <= num; i++)
            {
                if (num % i == 0)
                {
                    yield return i;
                }
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) v.begin(), v.end()
#define int long long
#define MAX 200000+5
int indegree[MAX];
bool vis[MAX];
void dfs(vector<int> adj[], int N, int i, vi& dp){
    vis[i] = true;
    for(int neigh : adj[i]){
        if(!vis[neigh]){
            dfs(adj, N, neigh, dp);
        }
        dp[i] = max(dp[i], 1 + dp[neigh]);
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int T = 1;
	//cin>>T;
	while(T-->0)
	{
        int N, M;
        cin>>N>>M;
        vector<int> adj[N+1];
        while(M--){
            int x, y;
            cin >> x >> y;
            adj[x].pb(y);
        }
        vi dp(N+1, 0);
        for(int i = 1; i <= N; i++){
            if(vis[i] == false)
                dfs(adj, N, i, dp);
        }
        /*dp[i] = longest path starting at node i*/
        cout << *max_element(all(dp));
	    cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 9984
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cassert>
using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); ++i)
#define FOREQ(i, a, b) for (ll i = (a); i <= (ll)(b); ++i)
#define DEC(i, k) for (ll i = (k); i >= 0; --i)
#define FORIT(i, c) for (__tyoeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define SZ(v) (ll)((v).size())
#define MEMSET(v, h) memset((v), (h), sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())
#define ALL(c) (c).begin(), (c).end()

ll ticket[1000];
ll ticketSum[1000];
ll n, m, a, b, p, q;
ll cnt;

ll calc(ll depth, ll lm) {
  if (depth == cnt || lm <= 0) { return abs(lm); }
  if (ticketSum[depth] < lm) { return abs(lm - ticketSum[depth]); }
  ll ret = m;
  ret = min(ret, calc(depth + 1, lm));
  ret = min(ret, calc(depth + 1, lm - ticket[depth]));
  return ret;
}

int main() {
  cin >> n >> m >> a >> b >> p >> q;
  if (a == 1 && b == 1) {
    ll use = m / (p + q);
    use = min(use, n - 1);
    printf("%lld\n", min(m - use * (p + q), abs(m - (use + 1) * (p + q))));
    return 0;
  }
  cnt = 0;
  {
    ll left = p;
    ll right = q;
    REP(i, n) {
      if (left + right > 2 * m) { break; }
      ticket[cnt++] = left + right;
      ll pleft = left;
      ll pright = right;
      left *= a;
      right *= b;
      if (left / a != pleft || right / b != pright) { break; }
    }
  }
  reverse(ticket, ticket + cnt);
  MEMSET(ticketSum, 0);
  for (ll i = cnt; i > 0; i--) {
    ticketSum[i - 1] = ticket[i - 1] + ticketSum[i];
  }
  ll ans = calc(0, m);
  printf("%lld\n", ans);
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	result := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		for {
			if a > 1 && a&1 == 0 {
				result++
				a = a / 2
			} else {
				break
			}
		}
	}
	fmt.Println(result)
}

// 引数処理
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	float x1, y1, x2, y2, x3, y3, xp, yp;
	float ss[3];
	float S;
	int i;
	
	while (scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
		ss[0] = (((x1 - x2) * (yp - y2)) - ((y1 - y2) * (xp - x2))) / 2;
		ss[1] = (((xp -x2) * (y3 - y2)) - ((x3 - x2) * (yp - y2))) / 2;
		ss[2] = (((x1 - xp) * (y3 - yp)) - ((x3 - xp) * (y1 -yp))) / 2;
	
		for (i = 0; i < 3; i++){
			if (ss[i] < 0){
				ss[i] *= -1;
			}
		}
		S = (((x1 - x2) * (y3 - y2) - (x3 - x2) * (y1 - y2))) / 2;
		if (S < 0){
			S *= -1;
		}
		if (ss[0] + ss[1] + ss[2] == S){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return (0);
}

Measured memory_bytes: 608
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
 　  tmp0 = input[0].split(" ");
    var A= parseInt(tmp0[0],10);
    var B=  parseInt(tmp0[1],10);
    var M=  parseInt(tmp0[2],10);
  //２行目、３行目を配列としてうけとる
      aList = input[1].split(" ").map(Number);
      bList = input[2].split(" ").map(Number);
  //配列の最小値をたす
     mab=Math.min.apply(null, aList)+Math.min.apply(null, bList);

    for(i=3;i<3+M;i++){
  
      tmp1 = input[i].split(" ");
      var x = parseInt(tmp1[0], 10);
      var y = parseInt(tmp1[1], 10);
      var c = parseInt(tmp1[2], 10);
      var tt=aList[x-1]+bList[y-1]-c;
      if (mab>tt){mab=tt;}
        }
  console.log(mab);
    }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 53940
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 400 + 10;
const int M = 1e5 + 10;
int x[M], y[M];
bool g[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    --x[i]; --y[i];
  }
  for (int i = 0; i < n; ++i) {
    g[i][i] = true;
    for (int j = m - 1; j >= 0; --j) {
      int u = x[j], v = y[j];
      if (!g[i][u] && g[i][v]) {
        g[i][u] = true;
      } else if (!g[i][v] && g[i][u]) {
        g[i][v] = true;
      } else if (g[i][u] && g[i][v]) {
        for (int k = 0; k < n; ++k) g[i][k] = true;
        break;
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      bool found = false;
      for (int k = 0; k < n; ++k) {
        if (g[i][k] && g[j][k]) {
          found = true;
          break;
        }
      }
      ret += !found;
    }
  }
  printf("%d\n", ret);
  return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, X, Y;
  cin >> N >> X >> Y;

  cout << min(X, Y) << " " << max(0LL, X+Y-N) << endl;  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashSet<Integer> A = new HashSet<Integer>();

		for(int i=0; i<N; i++){
			A.add(sc.nextInt());
		}
		
		if(A.size()<N){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
    }
}


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

using namespace std;
using ll = long long;

int K;

template<class T>
struct Vector {
  vector<T> v;
  Vector(int sz) : v(sz, 0) {}
  Vector() : v(0) {}
  Vector(vector<T> t) : v(t) {}
  inline auto& operator[](size_t pos) {
    return v[pos];
  }
  auto begin() {
    return v.begin();
  }
  auto end() {
    return v.end();
  }
  inline auto size() {
    return v.size();
  }
  inline auto push_back(T t) {
    v.push_back(t);
  }
  inline auto pop_back() {
    v.pop_back();
  }
  inline auto& back() {
    return v.back();
  }
  friend auto& operator>>(istream& lhs, Vector& rhs) {
    for (int i = 0; i < rhs.size(); i++) lhs >> rhs[i];
    return lhs;
  }
  friend auto& operator<<(ostream& lhs, Vector& rhs) {
    for (int i = 0; i + 1 < rhs.size(); i++) lhs << rhs[i] << endl;
    if (rhs.size()) lhs << rhs.back();
    return lhs;
  }
};

Vector<ll> calc(Vector<ll>& x, Vector<ll>& y)
{
  Vector<ll> res;
  for (ll X : x) {
    for (ll Y : y) {
      res.push_back(X + Y);
    }
  }
  sort(res.begin(), res.end(), greater<ll>());
  while (res.size() > K) res.pop_back();
  return res;
}

int main()
{
  int x, y, z;
  cin >> x >> y >> z >> K;
  Vector<ll> a(x), b(y), c(z);
  cin >> a >> b >> c;
  auto v = calc(a, b);
  v = calc(v, c);
  cout << v << endl;
}


Measured memory_bytes: 42600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

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

	long long dp[100 + 1][4][4][4];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				dp[3][i][j][k] = 1;
			}
		}
	}

	dp[3][0][1][2] = 0;
	dp[3][0][2][1] = 0;
	dp[3][1][0][2] = 0;

	for (int a = 3; a < n; a++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					for (int l = 0; l < 4; l++) {
						if (j == 0 && k == 1 && l == 2) continue;
						if (j == 1 && k == 0 && l == 2) continue;
						if (j == 0 && k == 2 && l == 1) continue;
						if (i == 0 && k == 1 && l == 2) continue;
						if (i == 0 && j == 1 && l == 2) continue;

						dp[a + 1][j][k][l] = (dp[a + 1][j][k][l] + dp[a][i][j][k]) % MOD;
					}
				}
			}
		}
	}
	long long ans = 0;

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans = (ans + dp[n][i][j][k]) % MOD;
			}
		}
	}

	cout << ans << endl;







}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dp[2][3010][2],p,np,n,m;
int main(){
	p=0,np=1;
	scanf("%d%d",&n,&m);
	dp[p][0][1]=1;
	n--,m--;
	for(int i=1;i<=n;++i)dp[p][i][0]=1;
	for(int i=1;i<=m;++i){
		swap(p,np);
		for(int j=0;j<=n;++j){
			dp[p][j][0]=dp[np][j][0]*2%mod;
			if(j<n)dp[p][j][0]=(dp[p][j][0]+dp[np][j+1][0])%mod;
			if(j>=1)dp[p][j][0]=(dp[p][j][0]+dp[np][j-1][0])%mod;
			dp[p][j][1]=dp[np][j][1]*2%mod;
			if(j<n)dp[p][j][1]=(dp[p][j][1]+dp[np][j+1][1])%mod;
			if(j>=1)dp[p][j][1]=(dp[p][j][1]+dp[np][j-1][1])%mod;
		}
		dp[p][0][1]=(dp[p][0][1]+dp[np][1][0])%mod;
		dp[p][0][0]=0;
	}
	int ans=0;
	for(int i=0;i<=n;++i)ans=(ans+dp[p][i][1])%mod;
	printf("%d",ans*4ll%mod);
}

Measured memory_bytes: 256
num = input()
length, res = len(num), 0
big, small = "9", "1"

for dig_len in range(1, length + 1, 2):
    if int(big) < int(num):
        res += int(big) - int(small) + 1
        big += "99"
        small += "00"
    else:
        res += int(num) - int(small) + 1

print(res)


Measured memory_bytes: 9080
#include <stdio.h>
#define LONG long

LONG fact(LONG a);
LONG n;
LONG main(void)
{
	
	scanf("%ld", &n);
	
	printf("%ld\n", fact(n));
	
	return (0);
}

LONG fact(LONG a)
{
	if (a == 1)return(a);
	return (a * fact(a - 1));
}

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

static const int MOD = 1000000007;
int S, R[2001];

void calcSeq() {
    for (int i = 3; i <= S; i++) {
        int ri = (R[i - 1] + R[i - 3]) % MOD;
        R[i] = (ri + MOD) % MOD;
    }
}

int main() {
    // 初項を初期化
    R[0] = 1; R[1] = 0; R[2] = 0;

    cin >> S;

    if (S <= 2) {
        cout << 0 << endl;
        return 0;
    }
    calcSeq();
    cout << R[S] << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <algorithm>
#define F first
#define S second
using namespace std;

int Q = 1e7, h1, h2, cut = 10;
int n, s, D, l, r, up, mx, cnt, mxx, xx, a[30], b[400][30], la[400], u[400], ans[400], o[400];
pair<int, int> c[400][30];
bool v[400][30];

int f(int p, int q1, int q2) {
	int sz = q2 - q1 + 1;
	return p * sz * (sz + 1) / 2;
}

int main()
{
	int i, j, k, t, x, t1, t2;
	srand(time(NULL));
	cin >> D;
	for (i = 0; i < 26; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 1; i <= D; i++) {
		mxx = -2e9;
		for (j = 0; j < 26; j++) {
			scanf ("%d", &b[i][j]);
		}
		for (j = 0; j < 26; j++) {
			cnt = b[i][j];
			for (k = 0; k < 26; k++) {
				if (k == j) continue;
				cnt -= (i - o[k]) * a[k];
			}
			if (cnt > mxx) {
				xx = j;
				mxx = cnt;
			}
		}
		s += mxx;
		o[xx] = i;
		ans[i] = u[i] = xx;
	}
//	for (i = 1; i <= D; i++) {
//		ans[i] = u[i] = 1;
//	}
	for(i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
/*
	for (i = 1; i <= D; i++){
//		scanf ("%d", &t);
		t = u[i] - 1;
		s += b[i][t];
		la[t] = i;
		for (j = 0; j < 26;j++) {
			s -= a[j] * (i - la[j]);
		}
		v[i][t] = 1;
	}
//	cout << s << endl;
//	cin >> Q;
	for (i =0; i < 26; i++) {
		v[0][i] = 1;
		v[D + 1][i] = 1;
	}
	mx = s;
	while (Q--) {
//		scanf ("%d %d", &t1, &t2);
		t1 = rand() % D + 1;
		t2 = rand() % 26;
		if (u[t1] == t2) t2 = (t2 + 1) % 26;
		x = u[t1];
		s -= b[t1][x];
		v[t1][x] = 0;
		v[t1][t2] = 1;
		u[t1] = t2;
		s += b[t1][t2];
		for (l = t1 - 1; l >= 0; l--) if (v[l][x]) break;
		for (r = t1 + 1; r <= D + 1; r++) if (v[r][x]) break;
		s += f(a[x], l + 1, t1 - 1);
		s += f(a[x], t1 + 1, r - 1);
		s -= f(a[x], l + 1, r - 1);
		for (l = t1 - 1; l >= 0; l--) if (v[l][t2]) break;
		for (r = t1 + 1; r <= D +1; r++) if (v[r][t2]) break;
		s += f(a[t2], l + 1, r - 1);
		s -= f(a[t2], l + 1, t1 - 1);
		s -= f(a[t2], t1 + 1, r - 1);
		if (s > mx) {
			up = 0;
			for (i = 1; i <= D; i++) {
				ans[i] = u[i];
			}
			mx = s;
		} else up++;
		if (up == cut) {
			up = 0;
			for (i = 1; i <= D; i++) {
				u[i] = ans[i];
			}
			s = mx;
		}
	}
	for (i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
*/
    return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int l, r;
  cin >> l >> r;

  int w = r - l;
  r = min(l + w, l + 2019);

  int ans = 2019;
  for (int i = l; i < r; ++i)
    for (int j = i + 1; j <= r; ++j) {
      int now = (ll)i * j % 2019;
      ans = min(ans, now);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			if((a==-1)&&(b==-1)&&(c==-1)&&(d==-1)){
				break;
			}
			
			double vz = Math.sin(Math.toRadians(a));
			double vx = Math.cos(Math.toRadians(a))*Math.cos(Math.toRadians(b));
			double vy = Math.cos(Math.toRadians(a))*Math.sin(Math.toRadians(b));

			double wz = Math.sin(Math.toRadians(c));
			double wx = Math.cos(Math.toRadians(c))*Math.cos(Math.toRadians(d));
			double wy = Math.cos(Math.toRadians(c))*Math.sin(Math.toRadians(d));

			double dot = vz*wz + vx*wx + vy * wy;
			double theta = Math.acos(dot);
			double R =6378.1;
			System.out.println((int)(R*theta+0.5));
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main () {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100002],wt[105],price[105];

int main()
{
    ll n,m,i,j,k,a,b,c,x,y,z,ans=0,mx=0;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        scanf("%lld%lld",&wt[i],&price[i]);
        mx+=price[i];

    }
    for(i=0;i<=n;i++){
        for(j=0;j<=mx;j++){
            //cout<<i<< "   " <<j<< "  " <<dp[i][j]<<endl;
            if(i==0){
                if(j==0)
                    dp[i][j]=0;
                else
                    dp[i][j]=-1;
                continue;
            }
            if(j<price[i])
            {

                dp[i][j]=dp[i-1][j];
                continue;
            }
            x=j-price[i];
            if(dp[i-1][x]==-1){
                dp[i][j]=dp[i-1][j];
                continue;
            }

            y=dp[i-1][x];
            if(y+wt[i]<=m){
                if(dp[i-1][j]==-1)
                    dp[i][j]=(y+wt[i]);
                else
                    dp[i][j]=min(dp[i-1][j],y+wt[i]);
                ans=max(ans,j);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
            //cout<<i<< "   " <<j<< "  " <<dp[i][j]<<endl;
        }

    }

    cout<<ans<<endl;
}


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

    public static class UnionFind {

        int[] id;
        int count;
        int[] weight;  // size indexed by root id

        public UnionFind(int n) {
            id = new int[n];
            weight = new int[n];
            count = n;
            for (int idx = 0; idx < id.length; idx++) {
                id[idx] = idx;
                weight[idx] = 1;
            }
        }

        public void union(int p, int q) {
            int pRoot = find(p);
            int qRoot = find(q);
            if (pRoot == qRoot) {
                return;
            }
            // make smaller root point to larger one
            if (weight[pRoot] < weight[qRoot]) {
                id[pRoot] = qRoot;
                weight[qRoot] += weight[pRoot];
            } else {
                id[qRoot] = pRoot;
                weight[pRoot] += weight[qRoot];
            }
            count--;
        }

        public int find(int p) {
            while (id[p] != p) {
                p = id[p];
            }
            return p;
        }

        public boolean connected(int p, int q) {
            return find(p) == find(q);
        }

        public int count() {
            return count;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        UnionFind uf = new UnionFind(n);
        int q = scanner.nextInt();
        while (q-- > 0) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            if (com == 0) {
                uf.union(x, y);
            } else {
                System.out.println(uf.connected(x, y) ? "1" : "0");
            }
        }
    }
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  string s;
  cin >> s;
  int many = 0;
  int many2 = 0;
  int lastrl = -1;
  int cnts[s.size()] = {0};
  s += ' ';
  for (int i=0; i<s.size()-1; i++){
      if (s[i] == 'R' && s[i+1] == 'L'){
          many++;
          cnts[i] += many/2;
          cnts[i+1] += many/2;
          if (many%2 == 1){
              cnts[i]++;
          }
          if (lastrl != -1){
              cnts[lastrl+1] += many2/2;
              if (many2%2 == 1){
                  cnts[lastrl+1]++;
              }
              cnts[lastrl] += many2/2;
          }
          many = 0;
          many2 = 0;
          lastrl = i;
      }else if (s[i] == 'R'){
          many++;
      }else{
          many2++;
      }
  }
  if (lastrl != -1){
      cnts[lastrl+1] += many2/2;
      if (many2%2 == 1){
          cnts[lastrl+1]++;
      }
      cnts[lastrl] += many2/2;
  }
  for (int i=0; i<s.size()-1; i++){
      cout << cnts[i] << " ";
  }
  return 0; 
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(a<b)swap(a,b);
  if(a%b==0)return b;
  return gcd(b,a%b);
}
int main(){
  ll n,k;cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)cin>>a[i];
  ll m=a[0];
  ll s=a[0];
  for(ll i=1;i<n;i++){
    m=gcd(m,a[i]);
    s=max(s,a[i]);
  }
  if(k%m==0&&s>=k)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N,K = map(int, input().split())
p = list(map(int, input().split()))


# In[44]:


le = [(x+1)/2 for x in p]
e = sum(le[:K])
ans = e
for i in range(N-K):
    e -= le[i]
    e += le[i+K]
    ans = max(ans ,e)
print(ans)


# In[ ]:






Measured memory_bytes: 32052