akhauriyash/Code-Regression huggingface dataset:
// TODO: 計算量が非常に多い気がする.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define pb push_back
#define a first
#define b second
const int MAX = 101010;
int memo[MAX];
vector<int> graph[MAX];
map<pair<int, int>, int> m; // 着色時の頂点ペア, 色を保存.
vector<pair<int, int>> o;   // 入力時の頂点ペアを保存.
set<int> color[MAX];
int maxColor;

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param s: 探索開始の頂点番号.
// @return: 特に無し.
void bfs(int s){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点は, 距離ゼロを指定.
    memo[s] = 0;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    
    // 4. キュー q が 空になるまで, 探索.
    while(!q.empty()){
        
        // 5. 頂点 u を キュー q から取り出す.
        int u = q.front();
        q.pop();
        
        // 6. 取り出した要素を処理.
        int c = 1;
        for(auto &e : graph[u]){
            // 6-1. 頂点u の 隣接する頂点e が, 未訪問だったら, キュー q に追加.
            if(memo[e] == 0 && e != s){
                // 頂点e を キュー q に追加.
                q.push(e);
                // 頂点e に 距離memo[u] プラス 1 を 加算.
                memo[e] += (memo[u] + 1);
                // 色を着色.
                // すでに使用している色があれば, Skip.
                while(color[u].count(c) != 0) c++;
                color[u].insert(c);
                color[e].insert(c);
                m[{u, e}] = c;
                m[{e, u}] = c;
                // 必要とする色の最大数を更新.
                maxColor = max(maxColor, c);
            }
        }
    }
}

int main(){
    
    // 1. 入力情報.
    int N, a, b;
    scanf("%d", &N);
    
    // 2. グラフ作成.
    rep(i, N - 1){
        scanf("%d %d", &a, &b);
        a--, b--;
        graph[a].pb(b);
        graph[b].pb(a);
        o.pb({a, b}); // オリジナルの入力情報.
    }
    
    // 3. 頂点 0 から 探索.
    bfs(0);
    // rep(i, N - 1) printf("%d ", memo[i]);
    // printf("\n");
    // printf("maxColor=%d\n", maxColor);
    // for(auto &p : m) printf("a=%d b=%d c=%d\n", p.a.a, p.a.b, p.b);
    
    // 4. 出力.
    printf("%d\n", maxColor);
    for(auto &p : o) printf("%d\n", m[p]);
    return 0;

}

Measured memory_bytes: 33908
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

ll n, ans = 0;

void dfs(ll x, bool a, bool b, bool c) {
  if(x > n) return;
  if(a&&b&&c) ++ans;

  dfs(x*10+7, true, b, c);
  dfs(x*10+5, a, true, c);
  dfs(x*10+3, a, b, true);
}

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

  cin >> n;
  dfs(0, false, false, false);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}
ll const M=1e9+7;
int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
		ll n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    for(int i=0;i<n;i++){
      cin>>arr[i];
      sum+=arr[i];
      sum%=M;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
      sum-=(arr[i]%M);
      sum=(sum+M)%M;
      sum%=M;
      ans+=((arr[i]%M)*sum)%M;
      ans%=M;
    }
    cout<<ans;
		
		
		
	}





}


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

int a[(uint)2e5];
int a2[(uint)2e5];
int main() {
  int n, k;
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  rep(j, k) {
    rep(i, n) {
      a2[max(0, i - a[i])]++;
      if (i + a[i] + 1 < n)
        a2[i + a[i] + 1]--;
    }
    bool comp = true;
    for (int i = 1; i < n; i++) {
      a2[i] += a2[i - 1];
      if (a2[i] != n) comp = false;
    }
    memcpy(a, a2, sizeof(int) * n);
    memset(a2, 0, sizeof(int) * n);
    if (comp) break;
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;

int n;
int a[N], b[N];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n + 1; i++) scanf("%d", a + i);
    for(int i = 1; i <= n; i++) scanf("%d", b + i);

    LL res = 0;
    for(int i = 1; i <= n; i++)
    {
        res += min(a[i], b[i]);
        b[i] = max(0, b[i] - a[i]);
        int t = min(a[i + 1], b[i]);
        a[i + 1] -= t;
        res += t;
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 1024
s = gets
if s[0] == s[1] && s[2] == s[3] && s[1] == s[2]
  puts "No"
elsif (s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3]) ||  (s[0] == s[3] && s[1] == s[2])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
N, a, b = map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    a0 = a
    b0 = b
    ans = 10 ** 18
    tmp = 0
    t = a-1
    tmp += t
    a -= t
    b -= t
    b -= 1
    tmp += 1
    tmp += (b-a)//2
    ans = min(tmp, ans)
    tmp = 0
    t = N-b0
    tmp += t
    b0 += t
    a0 += t
    a0 += 1
    tmp += 1
    tmp += (b0-a0)//2
    ans = min(tmp, ans)
    print(ans)

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

int main(){
	int a[4], b[2];
	for(int i = 0; i < 4; i++) cin >> a[i];
	for(int i = 0; i < 2; i++) cin >> b[i];
	sort(a, a + 4);
	sort(b, b + 2);
	reverse(a, a + 4);
	reverse(b, b + 2);
	cout << a[0] + a[1] + a[2] + b[0] << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j,k;
  cin>>n;
  int dp[n][3];
  for(i=0;i<n;i++)
  {
    for(j=0;j<3;j++)
      cin>>dp[i][j];
  }
  for(i=1;i<n;i++)
  {
    for(j=0;j<3;j++)
    {
      int x=INT_MIN;
      for(k=0;k<3;k++)
      {
        if(k!=j)
        {
          x=max(x,dp[i-1][k]+dp[i][j]);
        }
      }
      dp[i][j]=x;
    }
  }
  int mx=INT_MIN;
  for(i=0;i<3;i++)
  {
    mx=max(mx,dp[n-1][i]);
  } 
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
  int data[10][10];
  int da[10] = {0,0,0,0,0,0,0,0,0,0};
  int a[1024][1024];
  int h,w;

  cin >> h >> w;
  for(int i=0;i<10;i++){
    cin >> data[i][0] >> data[i][1] >> data[i][2] >> data[i][3] >> data[i][4] >> data[i][5] >> data[i][6] >> data[i][7] >> data[i][8] >> data[i][9];
  }
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      cin >> a[i][j];
      if (a[i][j]!=1 && a[i][j] != -1)da[a[i][j]]++;
    }
  }

  for (int i = 0; i < 10; i++)      // 経由する頂点
    for (int j = 0; j < 10; j++)    // 開始頂点
      for (int k = 0; k < 10; k++)  // 終端
        data[j][k] = min(data[j][k], data[j][i] + data[i][k]);

  int ans=0;
  for (int i=0;i<10;i++){
    ans+=da[i]*data[i][1];
  }
  cout <<ans;
  return 0;
}

Measured memory_bytes: 2944
let answer a b =
  let sa = a + b in
    if (sa mod 2) = 0 then
      if sa < 0 then
        sa / 2 * (-1) |> string_of_int
      else
        sa / 2 |> string_of_int
    else
      "IMPOSSIBLE"


let () = Scanf.scanf "%d %d" (fun a b -> print_endline (answer a b))


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

namespace Atcoder178
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var d = line[3];

            var ans = a * c;

            ans = Math.Max(ans, a * d);
            ans = Math.Max(ans, b * c);
            ans = Math.Max(ans, b * d);

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool solve(){
    int n;
    string s;
    cin >>n >>s;

    if(n%2==1) return false;
    n /= 2;
    rep(i,n)if(s[i]!=s[n+i]) return false;
    return true;
}

int main(){
    cout << (solve()?"Yes":"No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,m;
  cin>>n>>m;
  if(n>2&&m>2)
    cout<<(n-2)*(m-2)<<endl;
  else if(n==2||m==2)
    cout<<0<<endl;
  else if(n==1&&m==1)
    cout<<1<<endl;
  else if(n==1)
    cout<<m-2<<endl;
  else
    cout<<n-2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define mod 998244353
using namespace std;
void upd(int& x, int y){
	x += y;
	if (x >= mod)
		x -= mod;
}
int fpw(int x, int y){
	int ans = 1;
	for (int i = 1; i <= y; i <<= 1, x = 1LL * x * x % mod)
		if (y & i)
			ans = 1LL * ans * x % mod;
	return ans;
}
int fac[10004], inv[10004];
int C(int n, int m){
	if (n == m)
		return 1;
	if (n < 0 || m < 0 || n < m)
		return 0;
	return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int solve(int n, int m){
	return C(n - 1, m - 1);
}
int main(){
	fac[0] = 1;
	for (int i = 1; i <= 10000; ++ i)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[10000] = fpw(fac[10000], mod - 2);
	for (int i = 9999; i >= 0; -- i)
		inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
	int k, n;
	cin >> k >> n;
	for (int i = 2; i <= 2 * k; ++ i){
		int p = 0, ans = 0;
		for (int j = 1; j <= k; ++ j)
			if (j < i - j && i - j <= k)
				++ p;
		for (int q = 0; q <= p; ++ q){
			int cnt = 0;
			if (i & 1)
				upd(cnt, solve(n + k - 2 * p, q + k - 2 * p));
			else{
				upd(cnt, solve(n + k - 1 - 2 * p, q + k - 1 - 2 * p));
				upd(cnt, solve(n - 1 + k - 1 - 2 * p, q + k - 1 - 2 * p));
			}
			upd(ans, 1LL * cnt * C(p, q) % mod * fpw(2, q) % mod);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = readln.chomp.split.to!(int[]);
  writeln((a[0]*3+a[1])/2);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};
enum dir{
  Dup = 0,
  Dright = 1,
  Ddown = 2,
  Dleft = 3
};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

bool memo[16][4][20][20];

vector<string> g;
int r, c;

bool solve(int m, int d, int y, int x){
  if(memo[m][d][y][x]) return false;
  memo[m][d][y][x] = true;

  switch(g[y][x]){
  case '<':
    d = Dleft;
    break;
  case '>':
    d = Dright;
    break;
  case '^':
    d = Dup;
    break;
  case 'v':
    d = Ddown;
    break;
  case '_':
    if(m == 0) d = Dright;
    else d = Dleft;
    break;
  case '|':
    if(m == 0) d = Ddown;
    else d = Dup;
    break;
  case '?':
    REP(i,4){
      int xx = (x + c + _dx[i]) % c;
      int yy = (y + r + _dy[i]) % r;
      if(solve(m, i, yy, xx)) return true;
    }
    return false;
  case '.':
    break;
  case '@':
    return true;
    break;
  case '+':
    m = (m + 1) % 16;
    break;
  case '-':
    m = (m + 16 - 1) % 16;
    break;
  default:
    if(!isdigit(g[y][x])){
      printf("error %c\n", g[y][x]);
      exit(0);
    }
    m = g[y][x] - '0';
    break;
  }

  x = (x + c + _dx[d]) % c;
  y = (y + r + _dy[d]) % r;

  return solve(m, d, y, x);
}

int main(){
  cin >> r >> c;

  g = vector<string>(r);
  REP(i,r) cin>>g[i];

  puts(solve(0, Dright, 0, 0) ? "YES" : "NO");

  return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX 9999999

int v[20][20]={};
int cost[20][20]={};

int maxw;
int maxh;

int ans=0;

int coner(int h,int w){
  int r=0;
  if(h+1 < maxh && v[h+1][w  ])r++;
  if(w+1 < maxw && v[h  ][w+1])r++;
  if(w-1 > -1 && v[h  ][w-1])r++;
  if(h-1 > -1 && v[h-1][w  ])r++;
  return r;
}

int serch(int bcost,int h, int w){
  // std::cout << bcost << " : " <<  h << " : " << w << '\n';
  cost[h][w] = bcost+1;
  if(h+1<maxh)
  {
    if(v[h+1][w]==true && cost[h+1][w]+2<cost[h][w])
    {
      // int newcost = serch(cost[h][w],h+1,w);
      // if(newcost+1 < cost[h][w])cost[h][w] = newcost+1;
    }
    else if(v[h+1][w]==true && cost[h+1][w]>cost[h][w]+1)
    {
      int newcost = serch(cost[h][w],h+1,w);
      if(newcost+1 < cost[h][w])cost[h][w] = newcost+1;
    }
  }

  if(h-1>-1)
  {
    if(v[h-1][w]==true && cost[h-1][w]+1<cost[h][w])
    {
      // cost[h][w]=cost[h-1][w]+1;
    }
    else if(v[h-1][w]==true && cost[h-1][w]>cost[h][w]+1)
    {
      int newcost = serch(cost[h][w],h-1,w);
      if(newcost+1 < cost[h][w])cost[h][w] = newcost+1;
    }
  }

  if(w-1>-1)
  {
    if(v[h][w-1]==true && cost[h][w-1]+1<cost[h][w])
    {
      // cost[h][w]=cost[h][w-1]+1;
    }
    else if(v[h][w-1]==true && cost[h][w-1]>cost[h][w]+1)
    {
      int newcost = serch(cost[h][w],h,w-1);
      if(newcost+1 < cost[h][w])cost[h][w] = newcost+1;
    }
  }

  if(w+1<maxw)
  {
    if(v[h][w+1]==true && cost[h][w+1]+1<cost[h][w])
    {
      // cost[h][w]=cost[h][w+1]+1;
    }
    else if(v[h][w+1]==true && cost[h][w+1]>cost[h][w]+1)
    {
      int newcost = serch(cost[h][w],h,w+1);
      if(newcost+1 < cost[h][w])cost[h][w] = newcost+1;
    }
  }

  return cost[h][w];
}

void reset(){
  for (int i = 0; i < maxh; i++) {
    for (int k = 0; k < maxw; k++) {
      cost[i][k]=MAX;
    }
  }
}

int main() {
  std::cin >> maxh>>maxw;
  for (int i = 0; i < maxh; i++) {
    for (int k = 0; k < maxw; k++) {
      char temp;
      std::cin >> temp;
      v[i][k] = temp=='.'?true:false;
      cost[i][k] = MAX;
    }
  }

  bool flag=false;

  int min=MAX;
  int start[2]={};
  for (int i = 0; i < maxh; i++) {
    for (int k = 0; k < maxw; k++) {
      int now = coner(i,k);
      // std::cout << now;
      if(v[i][k]==true && now!=0){
        min=now;
        start[0]=i;
        start[1]=k;
        reset();
        serch(-1,start[0],start[1]);
        for (int i = 0; i < maxh; i++) {
          for (int k = 0; k < maxw; k++) {
            // if(v[i][k]==true)printf("%2d ",cost[i][k]);
            // else printf("   ");
            if(v[i][k] && cost[i][k]>ans)ans=cost[i][k];
          }
          // std::cout  << '\n';
        }
      }
    }
    // std::cout << '\n';
  }

  std::cout << ans << '\n';

  return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int d ;
  cin >> d ;
  if(d==25) cout << "Christmas"<<endl ;
  else if(d==24) cout << "Christmas Eve"<<endl ;
  else if(d==23) cout <<"Christmas Eve Eve"<<endl ;
  else cout <<"Christmas Eve Eve Eve"<<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  ull N; cin >> N;
  ull ans = 0;
  if (N == 1)ans = 0;
  else if (N == 2)ans = 1;

  else if ((N - 1) % 2 == 0) {
	ans = N * ((N - 1) / 2);
  }
  else {
	ans = (N * ((N - 1) / 2)) + ((N - 1) / 2 + 1);
  }

  cout << ans;


  //int A, B; cin >> A >> B;
  //int sum = A;
  //if (B == 1) {
	//cout << 0;
	//return 0;
  //}
  //int i = 0;
  //for (i = 0; sum < B; i++)sum += (A - 1);
  //cout << i + 1;

  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n;
    cin >> n;
    unordered_map<string, int> counter;
    int most = 0;
    FOR_EX(i, 0, n) {
        string s;
        cin >> s;
        counter[s]++;
        most = max(most, counter[s]);
    }
    vector<string> populars;
    for (auto &p : counter) {
        if (p.second == most) {
            populars.PB(p.first);
        }
    }
    sort(ALL(populars));
    for (auto &s : populars) {
        cout << s << endl;
    }
}


Measured memory_bytes: 25284
/* ITP1_5_B */

import java.io.*;
import java.util.*;

public class Main {
  public static void main (String[] args) throws java.lang.Exception {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0 && W==0) {
        return;   // 終了処理
      } else {
        // 最初の1行目を記述
        for(int i = 0; i < W; i++) {
          System.out.print("#");
        }
        System.out.println();
        // 2行目以降
        // 縦
        for(int x = 1; x < H-1; x++) {
          System.out.print("#");
          // 横
          for(int y = 1; y < W-1; y++) {
            System.out.print(".");
          }
          System.out.println("#");
        }
        // 最後の1行目を記述
        for(int i = 0; i < W; i++) {
          System.out.print("#");
        }
        System.out.println();
        System.out.println();
      }
    }
  }
}



Measured memory_bytes: 33996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
int n, ans;
vector <int> l;
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ans = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int x; cin >> x;
        l.pb(x);
    }
    sort(all(l));

    for(int i = n-1; i >= 2; --i) {
        for(int j = i-1; j >= 1; --j) {
			//cerr << i << ' ' << j << endl;
            auto a = upper_bound(all(l), l[i]-l[j]);
            auto b = l.begin() + j - 1;
            //cerr << *a << ' ' << *b << endl;
			ans += max((long long)(b-a+1),0ll);
        }
    }
    cout << ans;
}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  ll x; cin >> x;
  ll ans=x/11*2;
  if(x%11==0) drop(ans);
  cout << (x%11>6?ans+2:ans+1) << endl;
  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
	int i=1,x,n;
	scanf("%d",&n);
	do{
		x=i;
		if(x%3==0){
				printf(" %d",i);
		}else{
		do{
			if(x%10==3){
				printf(" %d",i);
				x=0;
			}else{
				x/=10;
			}
		}while(x);
	}
	}while(++i<=n);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main() {
	int N;
	scanf("%d", &N);
	int t;
	while (1) {
		if (N / 100 == 7) {
			printf("Yes");
			
			break;
		}
		else {
			t = N / 100;
			N = N - 100 * t;
		}
		if (N / 10 == 7) {
			printf("Yes");
			break;
		}
		else {
			t = N / 10;
			N = N - 10 * t;
		}
		if (N == 7) {
			printf("Yes");
			break;
		}
		else {
			printf("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1720
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {

    int n;
    cin >> n;
    cout << n * (n + 1) / 2 << endl;


    return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> ans(N+1);

  rep(i,M){
    cin >> a[i];
  }

  rep(i,N+1){
    ans[i]=0;
  }
  rep(i,M){
    ans[a[i]]=-1;
  }

  ans[0]=1;
  srep(i,1,N+1){
    if(ans[i]==-1){
      ans[i]=0;
    }
    else{
      if(i==1){
        ans[i]=1;
      }
      else{
        ans[i]=(long)(ans[i-1]+ans[i-2])%mod;
      }
    }
  }

  // rep(i,N+1){
  //   printf("ans[%d] = %d\n", i, ans[i]);
  // }

  printf("%d\n", ans[N]);



}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);

    sort(v.begin(),v.end());
    if(v[0]==v[1]&&v[0]!=v[2])
    {
        cout<<"Yes"<<endl;
    }
    else if(v[1]==v[2]&&v[1]!=v[0])
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
import math


def main():
    nd = [int(_x) for _x in input().split()]
    N = nd[0]
    D = nd[1]
    xys = []
    for i in range(N):
        xys.append([int(_x) for _x in input().split()])

    cnt = 0
    for xy in xys:
        dist = math.sqrt(xy[0]*xy[0] + xy[1]*xy[1])
        if dist <= D:
            cnt += 1
    print(cnt)


main()


Measured memory_bytes: 102776
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  unordered_map<int,int> mp;
  rep(i,N){
    int A; cin >> A;
    mp[A]++;
  }
  bool flag=false;
  int index=0;
  fore(i,mp){
    if(i.second % 2==0) i.second=2;
    else i.second=1;
    if(!flag && i.second==2){
      flag=true;
      index=i.first;
      continue;
    }
    if(flag && i.second==2){
      mp[index]=1;
      i.second=1;
      flag=false;
      continue;
    }
    //cout << i.second << endl;
  }
  int ans=0;
  fore(i,mp) ans+=i.second;
  if(flag) cout << ans-2 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int l[200];
int main(){
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>l[i];
    }
    sort(l,l+2*n);
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=l[i*2];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

int main(){
  int N,a,i;
  while(cin >> N && N!=0){
    for(int k=1;k<=N;k++){
      if((2*N)/k -k+1<=0)break;
      if(2*N%k!=0)continue;
      if(((2*N)/k -k+1)%2!=0)continue;
      a=((2*N)/k -k+1)/2;
      i=k;
    }
    cout << a << " " << i << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
n = int(input())

nums = list(map(int, input().split()))

total = sum(nums)
minVal = float('inf')
for i in range(1, n):
    a = sum(nums[0:i])
    b = total - a
    diff = abs(a - b)
    if diff < minVal:
        minVal = diff

print(minVal)


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

using namespace std;

const int Maxn = 2e5+7;

int n, ans;
int a[Maxn], pow2[35];
multiset<int> s;

int main()
{
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        s.insert(a[i]);
    }
    pow2[0] = 1;
    for(int i = 1; i < 31; ++i) pow2[i] = pow2[i-1]<<1;
    sort(a, a+n);

    for(int i = n-1; i; --i)
    {
        if(s.find(a[i]) == s.end()) continue;
        s.erase(s.find(a[i]));
        // a[i] < val <= 2*a[i] <= 2e9 < 2^31
        int val = *upper_bound(pow2, pow2+31, a[i]);
        if(s.find(val-a[i]) != s.end())
        {
            ans++;
            s.erase(s.find(val-a[i]));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template <typename A, typename B>string to_string(pair<A, B> p);

template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {return '"' + s + '"';}

string to_string(const char* s) {return to_string((string) s);}

string to_string(bool b) {return (b ? "true" : "false");}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}

template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unsigned long long ull;
typedef long long int lli;
typedef pair <int,int> ii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, c , d;
	cin >> a >> b >> c >> d;
	cout << max(a*c,max(a*d,max(b*c,b*d)));
    return 0;
}

Measured memory_bytes: 3668
/*input

*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n; string s, t;
	cin >> n >> s >> t;
	for(int i = 0; i < n; ++i)
		cout << s[i] << t[i];
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int w,h,i,j,t,c[]={1,0,-1,0,1},a[30][30],d,V=999,x,y;
	while(scanf("%d%d",&w,&h),w)
	{
		int m[30][30][4]={0};
		for(i=0;i<2*h-1;++i)
		{
			if(i&1)for(j=0;j<w;++j)scanf("%d",&t),m[i/2][j][3]=m[i/2+1][j][1]=!t;
			else for(j=0;j<w-1;++j)scanf("%d",&t),m[i/2][j][0]=m[i/2][j+1][2]=!t;
		}
		for(i=0;i<h;++i)for(j=0;j<w;++j)a[i][j]=V;
		typedef pair<int,int>P;
		queue<P>q;
		P p;
		q.push(P(0,0));
		q.push(P(-1,-1));
		d=1;
		while(q.size()>1)
		{
			p=q.front();q.pop();
			x=p.first,y=p.second;
			if(x<0){++d,q.push(p);continue;}
			if(a[y][x]<=d)continue;
			a[y][x]=d;
			for(i=0;i<4;++i)if(m[y][x][i])q.push(P(x+c[i],y+c[i+1]));
		}
		printf("%d\n",a[h-1][w-1]-V?a[h-1][w-1]:0);
	}
	return 0;
}

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

long long int k,n,sum1=0,sum2=0,sol;
int main()
{
    cin>>n>>k;
    int i=0,j=n,cnt;
    while(i<=n)
    {
        sum1=(sum1+i)%mod;
        sum2=(sum2+j)%mod;
        if(i>=k-1)
        {
            sol=(sol+(sum2-sum1+1+mod))%mod;
        }
        i++;
        j--;
    }
    cout<<sol;

}


Measured memory_bytes: 3636
n=int(input())
import math
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        ij=math.gcd(i,j)
        if ij==1:
            ans+=n
        else:
            for k in range(1,n+1):
                ans+=math.gcd(ij,k)
print(ans)

Measured memory_bytes: 9172
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, d) = readLongList()
    var ans = 0L
    repeat(n.toInt()) {
        val (x, y) = readLongList()
        if (x * x + y * y <= d * d) ans++
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 57308
import java.io.*;
import java.util.*;
public class Main {
    static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static String line;
    static  long n,k,T,N,m,A,B;
    static StringTokenizer st;
    static Scanner in = new Scanner(System.in);
    static char [] word;
    static Deque<Character> S  = new LinkedList<>();
    public static void main(String[] args) throws IOException {
      //D - String Formation Data structure
       line=br.readLine();
       for (int i=0;i<line.length();i++)
           S.addLast(line.charAt(i));
       T = Integer.parseInt(br.readLine());
       while (T-->0){
           st = new StringTokenizer(br.readLine());
           k = Integer.parseInt(st.nextToken());
           if (k==1){
               m^=(1);
           }else{
               int F = Integer.parseInt(st.nextToken());
               if (m==0){
                   if (F==1)
                       S.addFirst(st.nextToken().charAt(0));
                   else
                       S.addLast(st.nextToken().charAt(0));
               }else{
                   if (F==1)
                       S.addLast(st.nextToken().charAt(0));
                   else
                       S.addFirst(st.nextToken().charAt(0));
               }
           }
       }
    StringBuilder sb = new StringBuilder();
       while (!S.isEmpty()&&m==0){
           sb.append(S.pollFirst());
       }
        while (!S.isEmpty()&&m==1){
            sb.append(S.pollLast());
        }
       pw.print(sb.toString());
       pw.flush();

    }
}

Measured memory_bytes: 70320
import copy

# 入力
N=int(input())
C=list(input().split())
C_value=list(int(C[n][1:])for n in range(N))

# 安定性の判定を行う関数
def isStable(In,Out,In_value):
    flag=1
    for i in range(N):
        for j in range(i+1,N):
            for a in range(N):
                for b in range(a+1,N):
                    if In_value[i]==In_value[j] and In[i]==Out[b] and In[j]==Out[a]:
                        flag=0
    if flag==1:
        return 'Stable'
    else:
        return 'Not stable'

# バブルソート用のリスト作成
Cb=copy.copy(C)
Cb_value=list(int(Cb[n][1:])for n in range(N))

# バブルソート
for i in range(N):
    for j in range(N-1,i,-1):
        if Cb_value[j]<Cb_value[j-1]:
            Cb_value[j],Cb_value[j-1]=Cb_value[j-1],Cb_value[j]
            Cb[j],Cb[j-1]=Cb[j-1],Cb[j]

# 出力
print(' '.join(Cb))
print(isStable(C,Cb,C_value))


# 選択ソート用のリスト作成
Cs=copy.copy(C)
Cs_value=list(int(Cs[n][1:])for n in range(N))

# 選択ソート
for i in range(N):
    minj=i
    for j in range(i,N):
        if Cs_value[j]<Cs_value[minj]:
            minj=j
    Cs_value[i],Cs_value[minj]=Cs_value[minj],Cs_value[i]
    Cs[i],Cs[minj]=Cs[minj],Cs[i]

# 出力
print(' '.join(Cs))
print(isStable(C,Cs,C_value))



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

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

	vector<int> A( N+1 );
	for( int i = 0; i < N+1; ++i ) {
		cin >> A.at( i );
	}

	vector<int> B( N );
	for( int i = 0; i < N; ++i ) {
		cin >> B.at( i );
	}

	int64_t result = 0;

	for( int i = 0; i < N; ++i ) {
		if( A.at( i ) < B.at( i ) ) {
			result += A.at( i );

			int x = B.at( i ) - A.at( i );
			if( A.at( i+1 ) < x ) {
				result += A.at( i+1 );
				A.at( i+1 ) = 0;
			}
			else {
				result += x;
				A.at( i+1 ) -= x;
			}
		}
		else {
			result += B.at( i );
		}
	}

	cout << result << endl;
}


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

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

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

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


int main() {
  int N, M, K;
  int A[SIZE], B[SIZE];

  scanf("%d%d%d", &N, &M, &K);

  ll sumA = 0, sumB = 0;
  int ans = 0;

  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
    sumA += A[i];
    if (sumA <= K) ans = i + 1;
  }

  int t = N;

  for (int i = 0; i < M; i++) {
    scanf("%d", B + i);
    sumB += B[i];

    while (t && sumA + sumB > K) {
      t--;
      sumA -= A[t];
    }

    if (sumA + sumB <= K) {
      ans = max(ans, t + i + 1);
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 5388
n = int(input())
a = list(map(int, input().split()))

table = [0 for i in range(10**6+1)]
ans = 0
a.sort()
a.append(10**7)
for i in range(n):
    el = a[i]
    if table[el] != 0:
        continue
    else:
        if el != a[i+1]:
            ans += 1
    idx = el
    while idx <= 10**6:
        table[idx] += 1
        idx += el

print(ans)


Measured memory_bytes: 32064
#include <stdio.h>
int main(void){
	int S,h,m,s;

	scanf("%d",&S);

	h = S/3600;
	m = (S -(h*3600))/60;
	s = S-(h*3600+m*60);

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

Measured memory_bytes: 2708
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		int numberOfProcesses;
		int quantum;
		int clock = 0;
		String line;
		
		Queue<String> taskQueue = new LinkedList<String>();
		Queue<Integer> timeQueue = new LinkedList<Integer>();
		
		Scanner keyboard = new Scanner(System.in);
		Scanner input;
		
		line = keyboard.nextLine();
		
		input = new Scanner(line);
		
		numberOfProcesses = Integer.parseInt(input.next());
		quantum = Integer.parseInt(input.next());
		
		for(int i = 0; i < numberOfProcesses; i++) {
			line = keyboard.nextLine();
			input = new Scanner(line);
			
			taskQueue.add(input.next());
			timeQueue.add(Integer.parseInt(input.next()));
		}
		
		while(!taskQueue.isEmpty()) {
			
			String currentTask = taskQueue.remove();
			int currentTime = timeQueue.remove();
			
			if(currentTime > quantum) {
				currentTime = currentTime - quantum;
				
				taskQueue.add(currentTask);
				timeQueue.add(currentTime);
				
				clock = clock + quantum;
			}
			else {
				
				clock = clock + currentTime;
				
				System.out.print(currentTask + " ");
				System.out.println(clock);
			}
		}
		
		
		
	}

}


Measured memory_bytes: 230744
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n)
    {
        cin >> a[i];
        cin >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n % 2 == 0)
    {
        ll medA2 = a[(n / 2) - 1] + a[n / 2];
        ll medB2 = b[(n / 2) - 1] + b[n / 2];
        cout << medB2 - medA2 + 1 << endl;
    }
    else
    {
        ll medA = a[(n - 1) / 2];
        ll medB = b[(n - 1) / 2];
        cout << medB - medA + 1 << endl;
    }
}

Measured memory_bytes: 6044
from collections import deque

n = int(input())
d = deque()

for i in range(n):
    c = input()
    if ' ' in c:
        c, num = c.split()
        if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
    else:
        if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop()

print(' '.join(d))


Measured memory_bytes: 69732
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    string s; cin>>s;
    int gcnt=0,pcnt=0;
    int ans=0;
    rep(i,s.size()){
        if(s[i]=='g'){
            if(pcnt<gcnt){
                ans++;
                pcnt++;
            }else{
                gcnt++;
            }
        }else{
            if(pcnt<gcnt){
                pcnt++;
            }else{
                ans-=1;
                gcnt++;
            }
        }
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
ll H,W,h,w,sum = 0;
ll A[501][501];
int main(){
	cin >> H >> W >> h >> w;
	if(H%h==0 && W%w==0) cout << "No" << endl;
	else{
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(i%h==0 && j%w==0){
					A[i][j] = -h*w;
					sum -= h*w;
				}else{
					A[i][j] = 1;
					sum++;
				}
			}
		}
		ll t = 100;
		while(sum<=0){
			sum = 0;
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if(i%h==0 && j%w==0){
						A[i][j] = -t*(h*w-1)-1;
						sum += A[i][j];
					}else{
						A[i][j] = t;
						sum += A[i][j];
					}
				}
			}
			t *= 10;
		}
		cout << "Yes" << endl;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(j!=W) cout << A[i][j] << " ";
				else cout << A[i][j] << endl;
			}
		}
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;
  vi A0(N), B0(N), A(N), B(N);
  REP(0, N, i)
    cin >> A0[i];
  REP(0, N, i)
    cin >> B0[i];

  // B is increasing
  vector<pi> Bp(N);
  REP(0, N, i)
    Bp[i] = make_pair(B0[i], i);
  sort(all(Bp));

  REP(0, N, i) {
    B[i] = Bp[i].first;
    A[i] = A0[Bp[i].second];
  }

  i64 ans = 0;
  set<pi> As;
  REP(0, N, i) {
    As.insert(make_pair(A[i], i));
  }
  //
  REP(0, N, i) {
    //cout << As.size() << endl;
    if(A[i] > B[i]) {
      // find max j which satisfies A[j] <= B[i]
      // find min j A[j+1] > B[i]
      auto lb = As.lower_bound(make_pair(B[i], N));
      if(lb == As.begin()) {
	cout << "No" << endl;
	return 0;
      }
      lb--;
      i64 j = lb->second;
      As.erase(As.find(make_pair(A[i], i)));
      As.erase(As.find(make_pair(A[j], j)));
      As.insert(make_pair(A[i], j));
      swap(A[i], A[j]);
      //cout << "swap " << i << " " << j << endl;
      ans++;

    }
    else {
      As.erase(As.find(make_pair(A[i], i)));
    }    
  }

  cout << ((ans <= (N - 2)) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 12672
#include<stdio.h>
int main(void){
  int a,b,d,r=0;
  double f=0;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=1.0*a/b;
  printf("%d %d %.8lf\n",d,r,f);
  return 0;
}



Measured memory_bytes: 2092
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct ns
{
    string s;
};
int cmp(ns a,ns b)
{
    return a.s<b.s;
}
int main()
{
    ns s[200];
    int n,l;
    while(cin>>n>>l)
    {
      for(int i=0;i<n;i++)
        cin>>s[i].s;
      sort(s,s+n,cmp);
      for(int i=0;i<n;i++)
        cout<<s[i].s;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
char c[] = str.toCharArray();
        if (c[2] == c[3] && c[4] == c[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124