akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










ll gcd(ll a, ll b){
    return b? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}


int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll c = -1;
    REP(i, n){
        cin >> a[i];
        a[i] /= 2;
        ll cnt = 0, tmp = a[i];
        while(tmp % 2 == 0){
            tmp /= 2;
            cnt++;
        }
        if(c == -1){
            c = cnt;
        }
        else if(c != cnt){
            cout << 0 << endl;
            return 0;
        }
    }
    ll l = a[0];
    for(ll i = 1; i < n; i++){
        l = lcm(l, a[i]);
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 + (m - l) / (2 * l) << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string[] str = s.Split(' ');
            string[] strB = s.Split(' '), strS = s.Split(' ');


            BubbleSort(strB,n);
            isStable(str, strB, n);

            SelectionSort(strS,n);
            isStable(str, strS, n);

        }

        static void BubbleSort(string [] str, int n)
        {
            int p1 = 0, p2 = 0;

            for (int i = 0; i < n; i++)
            {
                p1 = p2;
                for (int j = n - 1; j > p1; j--)
                    if (int.Parse(str[j - 1][1].ToString()) > int.Parse(str[j][1].ToString())) { string tmp = str[j]; str[j] = str[j - 1]; str[j - 1] = tmp; p2 = j; }
                if (p1 == p2) break;
            }

            Console.WriteLine(string.Join(" ", str));
        }
         static void SelectionSort(string[] str, int n)
        {
            for (int i = 0; i < n; i++)
            {
                int mini = i;
                for (int j = i + 1; j < n; j++)
                    if (int.Parse(str[j][1].ToString()) < int.Parse(str[mini][1].ToString())) mini = j;
                if (i != mini) { string tmp = str[i]; str[i] = str[mini]; str[mini] = tmp; }
            }
            Console.WriteLine(string.Join(" ", str));
        }

        static void isStable(string [] x, string [] y, int n)
        {
            bool stable = true;

            for(int i=0;i<n-1;i++)
            {
                if (y[i][1] == y[i + 1][1])
                {
                    int indexA = Array.IndexOf(x, y[i]);
                    int indexB = Array.IndexOf(x, y[i + 1]);
                    if (indexA > indexB) { stable = false; break; }
                }
            }
            Console.WriteLine(stable?"Stable":"Not stable");
        }
    }
}

Measured memory_bytes: 8932
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;
  mll m;

  rep(i, S.size()) {
    char c = S[i];
    if (m[c] != 0) {
      COUT("no");
      return 0;
    } else {
      m[c]++;
    }
  }
  COUT("yes");
  return 0;
}

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

using namespace std;

const int W = 12, H = 12;
vector<string> field;

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

void mark(int x, int y) {
    if (field[y][x] == '1') field[y][x] = '0';
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
        if (field[ny][nx] == '0') continue;
        mark(nx, ny);
    }
}

int main() {
    field = vector<string>(12);

    string line;
    while(cin >> line) {
        field[0] = line;
        for (int i = 1; i <= 11; i++) {
            cin >> field[i];
        }

        int cnt = 0;
        for (int i = 0; i < field.size(); i++) {
            for (int j = 0; j < field[i].size(); j++) {
                if (field[i][j] == '1') {
                    cnt++;
                    mark(j, i);
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}



Measured memory_bytes: 3200
cards_a = gets.chomp.split('') + ['A']
cards_b = gets.chomp.split('') + ['B']
cards_c = gets.chomp.split('') + ['C']
current = 'a'
until cards_a.size == 0 || cards_b.size == 0 || cards_c.size == 0
  current = case current
  when 'a' then cards_a.shift
  when 'b' then cards_b.shift
  when 'c' then cards_c.shift
  end
end
puts current

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans = 0;
  rep(i,n) {
    while(a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aisingcontest2020
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] lrd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int l = lrd[0], r = lrd[1], d = lrd[2];
            int sum = 0;
            for(int i = l; i <= r; i++)
            {
                if (i % d == 0)
                    sum++;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 28296
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
int r[1300];
int main()
{
	int n;
	scanf("%d",&n);
	int a=n/100;
	int b=n%10;
	if (a==b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll n;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> a(n);
  rep(i,n) cin>>a[i];
  // all(sort(a));
  sort(all(a));
  reverse(all(a));
  ll ans = 0;
  rep(i,n){
    if(i%2==0) ans+=a[i];
    else ans-=a[i];
  }
  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}


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

using namespace std;

int main(void) {

	string s, t;

	char tmp;

	cin >> s >> t;

	bool jud = false;

	for (int i = 0; i < s.size(); i++)
	{
		if (s == t) {
			jud = true;
			break;
		}
		tmp = s[0];
		//cout << "tmp\n";
		s.erase(s.begin());
		//cout << "erase\n";
		s.push_back(tmp);
		//cout << "pushback\n";
	}

	if (jud)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}

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


int main(){
  int n,k;
  cin>>n>>k;
  int x=1;
  int ans=0;
  
  if(n==0)ans=1;
  while(n>=x){
    x*=k;
    ans+=1;
  }
    
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
void out(vector<pair<int, int>>& ans) {
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.first << " " << i.second << '\n';
  }
  exit(0);
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n, k;
  cin >> n >> k;
  if ((n - 1) * (n - 2) / 2 < k) {
    cout << -1 << endl;
    return 0;
  }
  vector<pair<int, int>> ans;
  for (int i = 1; i + 1 <= n; i++) {
    ans.emplace_back(i, n);
  }
  int cur = (n - 1) * (n - 2) / 2;
  if (cur == k) {
    out(ans);
  }
  //cerr << cur << endl;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      ans.emplace_back(i, j);
      cur--;
      if (cur == k) {
        out(ans);
      }
    }
  }
  //cerr << "here" << endl;
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
vector<vector<ll>> res;
vector<ll> a;
ll H,W,N;

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

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    vector<int> a(N+1);
    for (int i = 1; i <= N;i++) cin >> a[i];
    vector<vector<int>> c(H + 2, vector<int>(W + 2, -1));
    for (int i = 1; i <= H;i++)for (int j = 1; j <= W;j++) c[i][j] = 0;
    int dir = 0;
    int n = 1;
    int cnt = 0;
    int x, y; x = y = 1;
    while (cnt != H*W) {
        c[x][y] = n;
        a[n]--;
        if (a[n] == 0) {
            n++;
        }
        
        int nx = x + dx[dir], ny = y + dy[dir];
        if (c[nx][ny] != 0) {
            dir = (dir + 1) % 4;
            nx = x + dx[dir]; ny = y + dy[dir];
        }
        x = nx; y = ny;
        cnt++;
    }
    
    for (int i = 1; i <= H;i++) {
        for (int j = 1;j <= W;j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<double> v;
    double ans = 0;
    int a;
    for(int i = 0; i < n; i++) {
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    ans = v[0];
    for(int i = 1; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  int a,b,c,d;
  a=N/1000;
  b=(N-1000*a)/100;
  c=(N-1000*a-100*b)/10;
  d=(N-1000*a-100*b-10*c)/1;
  if(b!=c)
    {
      cout<<"No";
      return 0;
    }
  
  else
    {
      if(a==b)
	{
	  cout<<"Yes";
	  return 0;
	}
      if(b==d)
	{
	  cout<<"Yes";
	  return 0;
	}
      
    }
  cout<<"No";
  return 0;
}


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

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N + 1);
    for (int i = 1; i < N + 1; i++)
        cin >> L[i];
    for (int i = 1; i < N + 1; i++)
        L[i] += L[i - 1];
    cout << distance(L.begin(), upper_bound(L.begin(), L.end(), X)) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> vs(N+1), ws(N+1);
  FOR(i, 1, N+1) {
    cin >> vs[i] >> ws[i];
  }

  int Q;
  cin >> Q;
  vector<pair<int, int>> qs(Q);
  vector<int> ms(N + 1);
  F0R(i, Q) {
    cin >> qs[i].first >> qs[i].second;
    chmax(ms[qs[i].first], qs[i].second);
  }

  RF0(i, N+1) {
    chmax(ms[i / 2], ms[i]);
  }
  //Print(ms);

  vector<vector<int>> dp(2 << 9);
  dp[0].resize(ms[0] + 1);
  auto dfs = [&](auto dfs, int v, int depth)->void {

    if (depth > 9) return;
    if (v > N || ms[v] == 0) return;

    //cout << v << "," << ms[v] << newl;
    dp[v].resize(ms[v] + 1);
    int p = v >> 1;
    copy(dp[p].begin(), dp[p].begin() + min(ws[v], ms[v] + 1), dp[v].begin());
    
    FOR(i, ws[v], ms[v] + 1) {
      dp[v][i] = max(dp[p][i], dp[p][i - ws[v]] + vs[v]);
    }
    //Print(dp[depth]);
    dfs(dfs, v * 2, depth + 1);
    dfs(dfs, v * 2 + 1, depth + 1);
  };
  dfs(dfs, 1, 0);

  F0R(i, Q) {
    int result = -1;
    if (qs[i].first < dp.size()) {
      result = dp[qs[i].first][qs[i].second];
    }
    else {
      auto dfs = [&](auto dfs, int v, int val, int w)->void {

        if (v < dp.size()) {
          if (w <= qs[i].second) {
            chmax(result, dp[v][qs[i].second - w] + val);
          }
          return;
        }

        dfs(dfs, v >> 1, val + vs[v], w + ws[v]);
        dfs(dfs, v >> 1, val, w);
      };
      dfs(dfs, qs[i].first, 0, 0);
    }
    cout << result << newl;
  }
}
#endif


Measured memory_bytes: 408396
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v[N];
  for(int i=1;i<N;i++){
    int a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int ans=1;
  queue<int> que;
  que.push(0);
  std::vector<int> res(N,0),used(N,0);used[0]++;
  while(que.size()){
    int q=que.front();que.pop();
    int t=0;for(int a:v[q])t+=res[a];
    ans*=max(K-res[q]-t,0LL);ans%=MOD;
    for(int p:v[q]){
      res[p]++;
      if(used[p])continue;
      que.push(p);used[p]++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8948
n = int(input())
a = []
for i in range(n) :
    a_r = [num for num in input().split()]
    a.append(a_r)

sum = 0.0    
for tmp in a :
    if tmp[1] == "BTC" :
        sum += 380000.0*float(tmp[0])
    else :
        sum += float(tmp[0])
        
print(sum)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd

N = a_int()
P = list(map(float, readline().split()))

'''
dp[i,j]...表がちょうどj回出る確率、コイン[:i]を考慮したとき
dp[i+1,j]+=dp[i,j]*(1-P[i]) #配る、裏だった場合
dp[i+1,j+1]+= dp[i,j]*P[i] #表立った場合
'''
dp = [[0] * (N + 2) for _ in range(N + 2)]
dp[0][0] = 1
for i in range(N):
    for j in range(N):
        dp[i + 1][j] += dp[i][j] * (1 - P[i])  # 配る、裏だった場合
        dp[i + 1][j + 1] += dp[i][j] * P[i]  # 表立った場合

# 表がN//2+1以上回の確率を合計する
print(sum(dp[N][N // 2 + 1:]))
# print(*dp, sep='\n')


Measured memory_bytes: 216316
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rint register int
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int mat[1024][1024], sum[2][2048][2048], nmax, tot, d;
inline int query(int x1, int y1, int x2, int y2, int cnt[][2048]) {
	if (x2 < x1 || y2 < y1) return 0;
	int ret = cnt[x2][y2];
	if (x1) ret -= cnt[x1 - 1][y2];
	if (y1) ret -= cnt[x2][y1 - 1];
	if (x1 && y1) ret += cnt[x1 - 1][y1 - 1];
	return ret;
}
inline bool check(int mid) {
	rep (i, 0, d - 1) rep (j, 0, d - 1) {
		if (!query(i + mid, j + mid, i + d - 1, j + d - 1, sum[0]) && query(i, j, i + mid - 1, j + mid - 1, sum[1]) == tot) return true;
	}
	return false;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, x, y;
	cin >> n >> d;
	rep (i, 1, n) {
		cin >> x >> y;
		x = (x % d + d) % d;
		y = (y % d + d) % d;
		++mat[x][y];
	}
	rep (i, 0, d - 1) {
		rep (j, 0, d - 1) {
			nmax = max(nmax, int(sqrt(mat[i][j] - 1)));
		}
	}
	rep (i, 0, d - 1) {
		rep (j, 0, d - 1) {
			mat[i][j] = max(0, mat[i][j] - nmax * nmax);
		}
	}
	rep (i, 0, d - 1) {
		rep (j, 0, d - 1) {
			if (mat[i][j]) {
				if (mat[i][j] <= nmax) ++sum[0][i][j];
				else ++sum[1][i][j], ++tot;
			}
		}
	}
	rep (i, 0, d * 2 - 1) {
		rep (j, 0, d * 2 - 1) {
			sum[0][i][j] = sum[0][i % d][j % d];
			sum[1][i][j] = sum[1][i % d][j % d];
		}
	}
	rep (i, 1, 2 * d - 1) {
		rep (j, 0, 2 * d - 1) {
			sum[0][i][j] += sum[0][i - 1][j];
			sum[1][i][j] += sum[1][i - 1][j];
		}
	}
	rep (i, 0, 2 * d - 1) {
		rep (j, 1, 2 * d - 1) {
			sum[0][i][j] += sum[0][i][j - 1];
			sum[1][i][j] += sum[1][i][j - 1];
		}
	}
	/*rep (i, 1, 2 * d - 1) {
		rep (j, 1, 2 * d - 1) {
			sum[0][i][j] -= sum[0][i - 1][j - 1];
			sum[1][i][j] -= sum[1][i - 1][j - 1];
		}
	}*/
	int l = 0, r = d;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid - 1;
		else l = mid + 1;
	}
	cout << nmax * d + r << endl;
	return 0;
}

Measured memory_bytes: 37120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll f[1<<6][355],ans;
int n,C,L[15];
int main(){
	cin>>n>>C;
	for(int i=0;i<n;++i)cin>>L[i];
	sort(L,L+n);
	int tot=0,t=(1<<n-1)-1;
//	do{
//        ans+=f[(1<<n-1)-1][n*C];
//    }while(next_permutation(L,L+n-1));
	do{
		++tot;memset(f,0,sizeof(f));
		f[0][n*L[n-1]]=1;
		for(int i=1;i<=n*C;++i){
			if(i%n){
				int id=i%n-1,t=min(i+L[id]*n,n*C);
            for(int S=0;S<1<<n-1;++S)
            if(!(S>>id&1))
            for(int k=i;k<=n*C;++k)
            f[S|1<<id][max(k,t)]+=f[S][k];
//				for(int s=0;s<=t;++s){
//					if(!(s>>id&1)){
//						for(int k=i;k<=n*C;++k){
//							f[s|(1<<id)][max(t,k)]+=f[s][k];
//						}
//					}
//				}
			}
		}
//        ++tot;
//        memset(f,0,sizeof f);
//        f[0][n*L[n-1]]=1; 
//        for(int i=1;i<=n*C;++i)if(i%n){
//            const int id=i%n-1,t=min(i+L[id]*n,n*C);
//        }
		ans+=f[t][n*C];
	}while(next_permutation(L,L+n-1));
	printf("%.16lf\n",1.0*ans/tot/pow(C,n-1));
	return 0;
}

Measured memory_bytes: 3832
class Reader:
    def __init__(self):
        self.l = 0
        self.r = 0

    def __call__(self, s):
        l, r = s.split()
        if l > r:
            self.l += 3
        elif l < r:
            self.r += 3
        else:
            self.l += 1
            self.r += 1

    def __str__(self):
        return "{} {}".format(self.l, self.r)

reader = Reader()

n = int(input())
for _ in range(n):
    reader(input())
print(reader)

Measured memory_bytes: 7788
fn main() {
    proconio::input! {
        n: usize,
        d: [(usize, usize); n],
    }
    for i in 0..(n - 2) {
        if d[i].0 == d[i].1 && d[i + 1].0 == d[i + 1].1 && d[i + 2].0 == d[i + 2].1 {
            println!("Yes");
            return;
        }
    }

    println!("No");
}


Measured memory_bytes: 2160
L = [chr(i) for i in range(97, 123)]
s = list(input())
N = len(s)

ans = float("inf")
for i in L:
    c = 0
    X = s
    while True:
        if X.count(i) == N - c:
            break
        else:
            Y = []
            for j in range(N - c - 1):
                if X[j] == i or X[j + 1] == i:
                    Y.append(i)
                else:
                    Y.append(".")
            X = Y
        c += 1

    if c < ans:
        ans = c

print(ans)

Measured memory_bytes: 3064
def main():
    buf = input()
    L = int(buf)
    A = []
    for i in range(L):
        buf = input()
        A.append(int(buf))
    print(min(calc_move_count(A), calc_move_count(list(reversed(A)))))

def calc_move_count(A):
    stone_diff = []
    for i in A:
        if i == 0:
            stone_diff.append(1)
        elif i % 2 == 0:
            stone_diff.append(-1)
        else:
            stone_diff.append(0)
    no_left_sum = []
    for i in reversed(stone_diff):
        if not no_left_sum:
            no_left_sum.append(abs(i))
        else:
            no_left_sum.append(no_left_sum[-1] + abs(i))
    no_left_sum = list(reversed(no_left_sum))
    no_left_sum.append(0)
    move_left = [0]
    for i in A:
        if not move_left:
            move_left.append(i)
        else:
            move_left.append(move_left[-1] + i)
    move_right = []
    for i in reversed(A):
        if not move_right:
            move_right.append(i)
        else:
            move_right.append(move_right[-1] + i)
    move_right = list(reversed(move_right))
    move_right.append(0)
    dp = [[0, no_left_sum[0], 0, move_right[0]]]
    for i in range(len(A)):
        l = []
        l.append(min(move_left[i+1], dp[-1][0]+abs(stone_diff[i]+1)))
        l.append(min(move_left[i+1], l[0], dp[-1][1]+abs(stone_diff[i])-no_left_sum[i]) + no_left_sum[i+1])
        l.append(min(move_left[i+1], l[1]-no_left_sum[i+1], dp[-1][2]+abs(stone_diff[i]+1)))
        l.append(min(dp[-1][3], l[2] + move_right[i+1]))
        dp.append(l)
    return dp[-1][3]


if __name__ == '__main__':
    main()


Measured memory_bytes: 92144
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b >> c;
	if (a != b && b != c && a != c) {
		cout << '3' << "\n";
	}
	else if (a == b && b == c && a == c) {
		cout << '1' << "\n";
	}
	else {
		cout << '2' << "\n";
	}
	
	std::cin >> e;
}

Measured memory_bytes: 256
package main

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

func main() {
	In := ReadLineInt()
	Days := In[0]

	In = ReadLineInt()
	for _, v := range In {
		Days -= v
	}

	if Days <= -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(Days)
	}
}

/////////////////////////////////////////

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

func ReadBigLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := BufReader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 2488
import math
from collections import Counter

n = int(input())
f = math.factorial(n)
mod = 10 ** 9 + 7

factor = []
while f % 2 == 0:
    factor.append(2)
    f //= 2
x = 3
while x ** 2 <= f:
    if f % x == 0:
        factor.append(x)
        f //= x
    else:
        x += 2

if f != 1:
    factor.append(f)

c = Counter(factor)
ans = 1
for i in c.values():
    ans *= (i + 1)
    ans %= mod
    
print(ans)


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
		for (int i = 0; i < n - 1; i++) {
			String[] s = br.readLine().split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);

			List<Integer> list1 = map.get(a);
			if (list1 == null) {
				list1 = new ArrayList<Integer>();
				map.put(a, list1);
			}
			list1.add(b);

			List<Integer> list2 = map.get(b);
			if (list2 == null) {
				list2 = new ArrayList<Integer>();
				map.put(b, list2);
			}
			list2.add(a);
		}
		br.close();

		if (n == 1) {
			System.out.println("First");
			return;
		}

		int[] dep = new int[n + 1];
		Queue<Integer> que = new ArrayDeque<Integer>();
		que.add(1);
		dep[1] = 1;
		while (!que.isEmpty()) {
			Integer cur = que.poll();
			List<Integer> next = map.get(cur);
			for (Integer i : next) {
				if (dep[i] == 0) {
					que.add(i);
					dep[i] = dep[cur] + 1;
				}
			}
		}

		int max = 0;
		int num = 0;
		for (int i = 1; i < dep.length; i++) {
			if (dep[i] > max) {
				max = dep[i];
				num = i;
			}
		}

		dep = new int[n + 1];
		que = new ArrayDeque<Integer>();
		que.add(num);
		dep[num] = 1;
		while (!que.isEmpty()) {
			Integer cur = que.poll();
			List<Integer> next = map.get(cur);
			for (Integer i : next) {
				if (dep[i] == 0) {
					que.add(i);
					dep[i] = dep[cur] + 1;
				}
			}
		}

		max = 0;
		for (int i = 1; i < dep.length; i++) {
			if (dep[i] > max) {
				max = dep[i];
			}
		}

		if (max % 3 == 2) {
			System.out.println("Second");
		} else {
			System.out.println("First");
		}
	}
}


Measured memory_bytes: 93096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int saisyouti = 100000;
    vector<int>omosa(n);
    for(int i=0; i<n; i++){
        cin >> omosa.at(i);
    }
    
    for(int i=0; i<n; i++){
        int sum_1=0,sum_2=0;
        
        int ans=0;
        int zettaiti;
        
        for(int j=0; j<=i; j++){
            sum_1 += omosa.at(j);
        }
        for(int k=i+1; k<n; k++){
            sum_2 += omosa.at(k);
        }
        zettaiti = sum_1 - sum_2;
        if(zettaiti<0) zettaiti = -zettaiti;
        
       saisyouti = min(zettaiti,saisyouti);
        
        
    }
    cout << saisyouti << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=998244353;
const ll mod2=2e9+11;

ll mult(ll a,ll b)
{
    return (a*b)%mod1;
}
ll add(ll a,ll b)
{
    a+=b;
    if (a>=mod1)
        return a-mod1;
    return a;
}
ll sub(ll a,ll b)
{
    a-=b;
    if (a<0)
        return a+mod1;
    return a;
}
ll dp[301][301][301];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    string s;
    cin>>s;
    ll k;
    cin>>k;
    vector <ll> a;
    int cnt=0,cur=0;
    while (cur<s.size())
    {
        while (cur<s.size()&&s[cur]!='0')
            cnt++,cur++;
        a.pb(cnt);
        cnt=0;
        cur++;
    }
    if (s[(int)(s.size())-1]=='0')
        a.pb(0);
    reverse(all(a));
//    for (auto to:a)
//        cout<<to<<" ";
//    cout<<'\n';
    k=min(k,300ll);
    dp[0][0][0]=1;
    int n=a.size();
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<=k;j++)
        {
            for (int f=0;f<=j;f++)
            {
                dp[i][j][f]=add(dp[i][j][f],dp[i-1][j][f]);
                for (int h=a[i-1]-1;j+a[i-1]-h<=k&&h>=0;h--)
                {
                    dp[i][j+a[i-1]-h][f+a[i-1]-h]=add(dp[i][j+a[i-1]-h][f+a[i-1]-h],dp[i-1][j][f]);
                }
                for (int h=1;h<=f;h++)
                    dp[i][j][f-h]=add(dp[i][j][f-h],dp[i-1][j][f]);
            }
        }
    }
//    for (int i=1;i<=n;i++)
//    {
//        cout<<"Big: "<<i<<'\n';
//        for (int j=0;j<=k;j++)
//        {
//            cout<<"Small: "<<j<<'\n';
//            for (int f=0;f<=j;f++)
//                cout<<dp[i][j][f]<<" ";
//            cout<<'\n';
//        }
//    }
    ll ans=0;
    for (int i=0;i<=k;i++) {
   //     cout<<dp[n][i][0]<<'\n';
        ans = add(ans, dp[n][i][0]);
    }
    cout<<ans;

    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 110340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    str s; cin >> s;
    bool hitachi = false;
    if(s.size()%2 == 0){
        hitachi = true;
        for(int i=0; i<s.size()-1; i+=2){
            if(s[i] != 'h' || s[i+1] != 'i'){
                hitachi = false;
            }
        }
    }
    if(hitachi){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int d, n;
    cin >> d >> n;
    if (n == 100) cout << (n + 1) * (int)pow(100 , d);
    else cout << n * (int)pow(100 , d);
}

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

long long n[1000000] = { 0,0 };

long long Lucas(int N) {
	long long a;
	if (N == 0)
		return 2;
	if (N == 1)
		return 1;
	if (n[N] > 0)
		return n[N];
	a = Lucas(N - 1) + Lucas(N - 2);
	n[N] = a;
	return a;
}

int main()
{
	int N, ans;

	cin >> N;

	cout << Lucas(N) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct edge{
	int k,next;
}e[200005];
int n,a[100005],dep[100005],m,IN[100005],home[100005],cnt=-1;
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
int mx[100005];
void dfs1(int k){
	IN[a[k]]--;
	mx[a[k]]=max(mx[a[k]],mx[k]);
	if(!IN[a[k]]) dfs1(a[k]);
}
int f[100005];
void calc(int k){
	mx[k]=dep[k];
	int t=0;
	if(m==1&&dep[k]>1) t=1;
	for(int i=home[k];~i;i=e[i].next){
		dep[e[i].k]=dep[k]+1;
		calc(e[i].k);
		mx[k]=max(mx[k],mx[e[i].k]);
		if(mx[e[i].k]-dep[k]+1==m&&dep[k]>1) t=1; 
		f[k]+=f[e[i].k];
	}
	if(t) mx[k]=0;
	f[k]+=t;
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),IN[a[i]]++;
	for(int i=2;i<=n;i++) add(a[i],i);
	int g=a[1],sum=1;
	while(g!=1) g=a[g],sum++;
	calc(1);
	if(m>n-1){
		for(int i=1;i<=n;i++){
			if((m-dep[i])%sum!=0) return printf("%d",a[1]!=1),0;
		}
		return puts("0"),0;
	}
	for(int i=1;i<=n;i++){
		if(dep[i]<=m&&(m-dep[i])%sum!=0) return printf("%d",f[1]+(a[1]!=1)),0;
	}
	printf("%d",f[1]);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,ans,A[200005],dp[200005],lst[200005],nxt[200005];
int dfs(int now) {
//	printf("now=%d\n",now);
	if(dp[now]!=-1)return dp[now];
	if(now>=n+1)return 1;
	int s=dfs(now+1);
	if(nxt[now]&&nxt[now]!=now+1)s+=dfs(nxt[now]);
	if(s>=mod)s-=mod;
	return dp[now]=s;
}
int main() {
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",&A[i]);
	for(int i=1; i<=n; i++) {
		nxt[lst[A[i]]]=i;
		lst[A[i]]=i;
	}
	ans=dfs(1);
	printf("%d",ans);
	return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		int w[] =new int[10];
		int k[]  =new int[10];
		for(int i = 0; i <10;i++){
			w[i] = sc.nextInt();
			
		}
		for(int j = 0; j< 10;j++){
			k[j] = sc.nextInt();
		}
		
		Arrays.sort(w);
		Arrays.sort(k);
		System.out.println((w[7]+w[8]+w[9]) + " "+(k[7]+k[8]+k[9]));
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int h, w;

bool is_inside(int x, int y) {
	return 0 <= x && x < w && 0 <= y && y < h;
}

int main() {
	cin >> h >> w;

	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				continue;
			}

			bool ok = false;
			for (int k = 0; k < 4; k++) {
				int nx = j + dx[k];
				int ny = i + dy[k];
				if (is_inside(nx, ny) && s[ny][nx] == '#') {
					ok = true;
					break;
				}
			}
			if (!ok) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////
int main()
{
	string s;
	cin>>s;

	rep(i,s.size())
	{
		if(s[i]<=67)s[i]+=23;
		else s[i]-=3;
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
ll n;
cin>>n;
ll a[n],b[n-1],c[n],ans=0;
for(i=0;i<n-1;i++)
cin>>b[i];
ans+=b[n-2];
ans+=b[0];
for(i=0;i<n-2;i++)
ans+=min(b[i],b[i+1]);
cout<<ans;
return 0;
}

Measured memory_bytes: 256
s = input()

INF = 10**100

RL = []
res = []
for i in range(len(s)):
    if s[i] == 'R' and s[i+1]=='L':
        RL.append(i)
for x in RL:
    l = x
    r = x+1
    LL = 0
    RR = 0
    for i in range(l,-1,-1):
        if s[i] == 'R':
            if (l-i)%2==0:
                RR+=1
            else:
                LL+=1
        else:
            break
    for i in range(r,len(s)):
        if s[i] == 'L':
            if (i-r)%2 ==0:
                LL+=1
            else:
                RR+=1
        else:
            break
    res.append((RR,LL))
d = [0]*len(s)
for i in range(len(RL)):
    idx = RL[i]
    d[idx] = res[i][0]
    d[idx+1] = res[i][1]
for x in d:
    print(x,end=" ")
print("")


Measured memory_bytes: 10360
N,K,X,Y = [int(input()) for i in range(4)]

if N <= K:
    print(N * X)
else:
    S = K * X #最初の宿泊金額
    p = N - K #残りの日数
    s = p * Y #残りの宿泊金額
    S += s #足す
    print(S)


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  string s;
  vector<vector<char>> v(a*2, vector<char>(b));
  for(int i=0; i<a; i++) {
    cin >> s;
    for(int j=0; j<b; j++) {
      for(int k=2*i; k<2*i+2; k++) {
        v[k][j] = s[j];
      }
    }
  }
  
  for(int i=0; i<a*2; i++) {
    for(int j=0; j<b; j++) {
      cout << v[i][j];
      if(j==b-1) cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		int L[] = new int[M];
		int R[] = new int[M];

//		int OK[] = new int[N] ;
//		for( int i = 0 ; i < N ; i ++ ) {
////			OK[i] = 0 ;
//			OK[i] = 1 ;
//		}

		int lmax = 1 ;
		int rmin = N ;
		for( int i = 0 ; i < M ; i ++ ) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
			if(lmax < L[i] ) {
				lmax = L[i] ;
			}
			if(R[i] < rmin  ) {
				rmin = R[i] ;
			}
		}

//		System.out.println("lmax =" + lmax + ",rmin=" + rmin );
//		for( int i = 0 ; i < M ; i ++ ) {
//			System.out.println("L[i] =" + L[i] + ",R[i]=" + R[i] );
//		}
		if(rmin < lmax ) {
			System.out.println(0);
		}else {
			System.out.println(rmin - lmax + 1);
		}

	}

}


Measured memory_bytes: 84816
n = input()
l1 = []

for i in range(n):
	t = input()
	l1.append(t)

l2 = sorted(l1)

s1, s2 = set([]), set([])

for i in range(n):
	if i % 2 == 1:
		s1.add(l1[i])
		s2.add(l2[i])

print len(s1) - len(s1.intersection(s2))


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

namespace AtCoderPractice
{
    class ForbiddenList
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int x = int.Parse(input[0]);
            int n = int.Parse(input[1]);
            if(n == 0)
            {
                Console.WriteLine(x);
                return;
            }
            int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = 0;
            var lists = new List<int>();
            int[] diff;

            for(int i = 0; i <= 101; i++)
            {
                int frag = 0;
                for (int j = 0; j < n; j++)
                {
                    if(i == p[j])
                    {
                        frag = 1;
                        break;
                    }
                }
                if(frag != 1)
                {
                    lists.Add(i);
                }
            }
            diff = new int[lists.Count];
            for(int i = 0;i < lists.Count; i++)
            {
                diff[i] = Math.Abs(x - lists[i]);
                if(i == 0)
                {
                    min = lists[i];
                }
                else if (diff[i] < diff[i-1])
                {
                    min = lists[i];
                }
            }
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 28228
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=200005,K=1000000007;
struct datas { int num; bool neg; } cow[maxn];
int n,m,cntA,cntB,lastA,lastB,ans;
bool cmp(datas A,datas B) { return A.num>B.num; }
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&cow[i].num);
		if (cow[i].num<0)
		{
			cow[i].num=-cow[i].num;
			cow[i].neg=true;
		}
	}
	if (n==m)
	{
		ans=1;
		for (int i=1;i<=n;i++)
		{
			ans=(LL)ans*cow[i].num%K;
			if (cow[i].neg && ans) ans=K-ans;
		}
		printf("%d\n",ans);
		return 0;
	}
	sort(cow+1,cow+1+n,cmp);
	for (int i=1;i<=m;i++)
		if (!cow[i].neg)
			cntA++,lastA=i; else
			cntB++,lastB=i;
	if (!(cntB&1))
	{
		ans=1;
		for (int i=1;i<=m;i++) ans=(LL)ans*cow[i].num%K;
	} else
	{
		int resA=-1,resB=-1;
		for (int i=m+1;i<=n;i++)
			if (!cow[i].neg)
			{
				resA=cow[i].num;
				break;
			}
		for (int i=m+1;i<=n;i++)
			if (cow[i].neg)
			{
				resB=cow[i].num;
				break;
			}
		if (!lastA && resA==-1)
		{
			ans=1;
			for (int i=n-m+1;i<=n;i++)
			{
				ans=(LL)ans*cow[i].num%K;
				if (cow[i].neg && ans) ans=K-ans;
			}
		} else
		if (lastA && resB!=-1 &&
			(resA==-1 || (LL)resB*cow[lastB].num>=(LL)resA*cow[lastA].num))
		{
			ans=resB;
			for (int i=1;i<=m;i++)
				if (i!=lastA) ans=(LL)ans*cow[i].num%K;
		} else
		{
			ans=resA;
			for (int i=1;i<=m;i++)
				if (i!=lastB) ans=(LL)ans*cow[i].num%K;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5324
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n;

	scanf("%d",&n);

	set<int>s;

	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
		if(s.count(x)){
			s.erase(x);
		}
		else	s.insert(x);
	}
	printf("%d\n",sz(s) );
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define mod 1000000007
#define maxn 300005
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
const long long inf = 2e18;
int n,m;
pp a[maxn]; int ans[maxn];
bool cmp (pp x1, pp x2){
	return (x1.second-x1.first)<(x2.second-x2.first);
}
int fen[maxn];
void add (int pos,int val){
	for (int i=pos;i<=m;i+=(i&(-i))){
		fen[i]+=val;
	}
}
int sum (int pos){
	int val=0;
	for(int i=pos; i>0; i-=(i&(-i))){
		val+=fen[i];
	}
	return val;
}

main(){
	//ios::sync_with_stdio(false); cin.tie(0);
	//freopen(".inp","r",stdin); freopen(".out","w",stdout);
	//freopen("inp.txt","r",stdin);
	cin>>n>>m; int i,j,k;
	for (i=1;i<=n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1,a+n+1,cmp);
	int spec=n;
	j=1;
	for (i=1;i<=m;i++){
		while (j<=n&&a[j].second-a[j].first+1<i){
			//cout<<i<<" "<<j<<" "<<a[j].second-a[j].first+1<<'\n';
			spec--;
			add(a[j].first,1); 
			if (a[j].second<m){
				add(a[j].second+1,-1);
			}
			j++;
		}
		for (k=i;k<=m;k+=i){
			ans[i]+=sum(k);
		}
		ans[i]+=spec;
	}
	for(i=1;i<=m;i++) cout<<ans[i]<<'\n';
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());
            Console.WriteLine("{0:f6} {1:f6}", r * r * Math.PI, 2 * r * Math.PI);
        }
    }
}

Measured memory_bytes: 5784
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Alter Altar
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int rn = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R') rn++;

  int c = 0;
  for (int i = rn; i < n; i++)
    if (s[i] == 'R') c++;

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;

signed main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i) >> B.at(i) >> C.at(i);
  
  vector<vector<int>> dp(3, vector<int>(N, 0));
  //今A, B, Cを選んだ場合に取れる選択の最大値
  dp.at(0).at(0) = A.at(0);
  dp.at(1).at(0) = B.at(0);
  dp.at(2).at(0) = C.at(0);
  for( int i = 1; i < N; i++ ){
    for( int j = 0; j < 3; j++ ){ 
      if( j == 0 ){ //Aを選んだ場合
        dp.at(j).at(i) = A.at(i) + max( dp.at(1).at(i-1), dp.at(2).at(i-1) );
      }else if( j == 1 ){ //Bを選んだ場合
        dp.at(j).at(i) = B.at(i) + max( dp.at(0).at(i-1), dp.at(2).at(i-1) );
      }else{ //Cを選んだ場合
        dp.at(j).at(i) = C.at(i) + max( dp.at(0).at(i-1), dp.at(1).at(i-1) );
      }
    }
  }
  cout << max( { dp.at(0).at(N-1), dp.at(1).at(N-1), dp.at(2).at(N-1) } ) << endl;
  
  
}


Measured memory_bytes: 5760