akhauriyash/Code-Regression huggingface dataset:
import java.sql.SQLOutput;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            String x = sc.next();
            int n = sc.nextInt();
            for(int i=0 ; i < n ; i++){
                String order = sc.next();
                if(order.equals("print")){
                    int a = sc.nextInt();
                    int b = sc.nextInt();
                    System.out.println(x.substring(a,b+1));
                }else if(order.equals("reverse")){
                    int a = sc.nextInt();
                    int b = sc.nextInt();
                    char y[] = new char[b-a+1];
                    for(int j=0 ; j < b-a+1 ; j++){
                        y[j] = x.charAt(b-j);
                    }
                    x = x.substring(0,a) + String.valueOf(y) + x.substring(b+1,x.length());
                }else if(order.equals("replace")){
                    int a = sc.nextInt();
                    int b = sc.nextInt();
                    String c = sc.next();
                    x = x.substring(0,a) + c + x.substring(b+1,x.length());
                }
            }
    }
}



Measured memory_bytes: 29936
n,A,B,C = map(int,input().split())
l = [int(input()) for i in range(n)]
inf = 10 ** 9

def dfs(i,a,b,c):
    if i == n:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return inf
    ret0 = dfs(i+1, a, b, c)
    ret1 = dfs(i+1, a + l[i], b, c) + 10
    ret2 = dfs(i+1, a, b + l[i], c) + 10
    ret3 = dfs(i+1, a, b, c + l[i]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a,b string
	fmt.Scan(&a,&b)
	
  	num := a + b
	
	judge := false
	numInt,_ := strconv.Atoi(num)
	for i := 0; i * i < 100100; i++ {
      if i * i == numInt {
			judge = true
			break;
		}
	}
	if judge {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N As Integer = Console.ReadLine()
        Dim S As String = Console.ReadLine()
        Dim alp As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        Console.WriteLine(Trans(S, alp, alp.Substring(N) + alp.Substring(0, N)))
        Return
    End Sub

    Shared Function Trans(ByVal S As String, ByVal f As String, ByVal t As String) As String
        For i As Integer = 0 To S.Length - 1
            Dim idx = f.indexOf(S(i))
            S = S.Substring(0, i) + t(idx) + S.Substring(i + 1)
        Next
        Trans = S
    End Function
End Class


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

using namespace std;
typedef long long ll;

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans;
    ll x = min(b - 1, n);
    ans = (a * x / b) - a * (x / b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n,ans,c=0;
	string s;
	cin>>n>>s;
	fo(i,0,n) if(s[i]!='#')c++;
	ans=c;
	fo(i,0,n){
		if(s[i]!='.')c++;
		else c--;
		ans=min(ans,c);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#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(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n;
  cin >> n;
  map<string,int>mp;
  for(int i=0;i<n;i++){
    string tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int max_value = 0;
  for(auto x:mp){
    max_value = max(max_value,x.second);
  }
  for(auto x:mp){
    if(x.second == max_value){
      cout<< x.first <<endl;
    }
  }

}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  for(ll i=0;i<n;i++) {
    ll v;
    cin >> v;
    a[i]={v,i};
  }
  sort(a.rbegin(),a.rend());
  set<ll> al,ar;
  al.insert(-a[0].second);
  al.insert(1);
  al.insert(-n);
  ar.insert(a[0].second);
  ar.insert(-1);
  ar.insert(n);
  ll ans=0;
  for(ll i=1;i<n;i++) {
    ll v=a[i].first;
    ll id=a[i].second;
    auto r=ar.lower_bound(id);
    auto tr=ar.upper_bound(*r);
    auto l=al.lower_bound(-id);
    auto tl=al.upper_bound(*l);
    ll dr=min(max(*tr,*r),n)-*r;
    ll dl=-*l+-max(-max(*tl,*l),-1LL);
    ans+=v*dr*(id+*l);
    ans+=v*(*r-id)*dl;
    al.insert(-id);
    ar.insert(id);
  }
  cout << ans << endl;
}

Measured memory_bytes: 13988
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int r, c;
int n;
struct edge {
	int to; ll cost;
};
vector<edge> G[1 << 18];
bool used[1 << 18];
ll val[1 << 18];
int main() {
	cin >> r >> c >> n;
	rep(i, n) {
		int x, y; ll a; cin >> x >> y >> a; x--; y--;
		G[x].push_back({ y + r,a });
		G[y + r].push_back({ x,a });
	}
	string ans = "Yes";
	rep(i, r + c) {
		if (used[i])continue;
		if (G[i].size() == 0)continue;
		ll mi[2] = { INF,INF };
		queue<int> q;
		q.push(i); used[i] = true; val[i] = 0; mi[i >= r] = min(mi[i >= r], (ll)0);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			rep(j, G[v].size()) {
				int to = G[v][j].to;
				ll nc = G[v][j].cost-val[v];
				if (used[to]) {
					if (val[to] != nc)ans = "No";
				}
				else {
					used[to] = true;
					val[to] = nc;
					mi[to >= r] = min(mi[to >= r], nc);
					q.push(to);
				}
			}
		}
		if (mi[0] + mi[1] < 0)ans = "No";
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 14464
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64
    }

    let mut ret = 1u64;
    for i in (1..).take_while(|i| i * i <= n) {
        if n % i == 0 {
            ret = i;
        }
    }
    let a = format!("{}", ret).len();
    let b = format!("{}", n / ret).len();
    println!("{}", std::cmp::max(a, b));
}



Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    // Your code here!
    int a , b, c;
 
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    
    if(c <= b && c >= a)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}


Measured memory_bytes: 128
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const n = parseInt(params1[0]);
  const x = params2.map(x => parseInt(x));

  const y = sort(x);

  const l = Math.floor(n / 2);
  const y1 = y[l - 1];
  const y2 = y[l];

  x.forEach(a => {
    const b = (a <= y1) ? y2 : y1;
    console.log(b);
  });
}

function sort(a: number[]): number[] {
  let b: number[] = [];
  a.forEach(n => {
    b.push(n);
  });

  b.sort((x, y) => x - y);
  
  return b
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 43712
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	vi dp(31);
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;

	FOR(i, 4, 31) {
		dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
	}

	int n;

	while(cin >> n, n) {
		cout << (dp[n]/3650)+1 << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    int a,b;
    char p;
    cin >> a >> p >> b;
    if (p=='+'){
        cout << a + b << endl;
    }
    else{
        cout << a - b << endl;
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(n):
  l1.append(list(map(int,input().split())))
for i in range(m):
  l2.append(list(map(int,input().split())))
for i in range(n):
  l=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])
  n=0
  for j in range(1,m):
    if l>abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1]):
      l=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])
      n=j
    else:
      pass
  print(n+1)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N=200005;
vector<int> vct[N];
int n,q,i,j,b[N],mn[N*5],add[N*5],rt[N],ans;
void built(int o,int l,int r)
{
	if(l==r)
	{
		if(l!=0)
			mn[o]=1<<30;
		else
			mn[o]=0;
		return;
	}
	int mid=l+r>>1;
	built(o<<1,l,mid);
	built(o<<1|1,mid+1,r);
	mn[o]=min(mn[o<<1],mn[o<<1|1]);
}
void pushdown(int o,int l,int r)
{
	if(add[o])
	{
		add[o<<1]+=add[o],add[o<<1|1]+=add[o];
		mn[o<<1]+=add[o],mn[o<<1|1]+=add[o];
		add[o]=0;
	}
}
void update2(int o,int l,int r,int x,int y,int z)
{
	if(l>=x&&r<=y)
	{
		mn[o]+=z;
		add[o]+=z;
		return;
	}
	pushdown(o,l,r);
	int mid=l+r>>1;
	if(x<=mid)
		update2(o<<1,l,mid,x,y,z);
	if(y>mid)
		update2(o<<1|1,mid+1,r,x,y,z);
	mn[o]=min(mn[o<<1],mn[o<<1|1]);
}
void update(int o,int l,int r,int x,int y)
{
	if(l==r)
	{
		mn[o]=min(mn[o],y);
		return;
	}
	pushdown(o,l,r);
	int mid=l+r>>1;
	if(x<=mid)
		update(o<<1,l,mid,x,y);
	else
		update(o<<1|1,mid+1,r,x,y);
	mn[o]=min(mn[o<<1],mn[o<<1|1]);
}
int query(int o,int l,int r,int x,int y)
{
	if(l>=x&&r<=y)
		return mn[o];
	pushdown(o,l,r);
	int mid=l+r>>1,rtn=1<<30;
	if(x<=mid)
		rtn=query(o<<1,l,mid,x,y);
	if(y>mid)
		rtn=min(rtn,query(o<<1|1,mid+1,r,x,y));
	return rtn;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",b+i);
		if(b[i]==0)
			++ans;
	}
	built(1,0,n);
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&i,&j);
		vct[i].push_back(j);
	}
	for(i=1;i<=n;++i)
	{
		for(j=vct[i].size()-1;j>=0;--j)
			update(1,0,n,vct[i][j],query(1,0,n,0,vct[i][j]-1));
		if(b[i]==1)
			update2(1,0,n,0,i-1,1);
		else
			update2(1,0,n,0,i-1,-1);
	}
	ans+=query(1,0,n,0,n);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 17536
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections

def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    c=collections.Counter(arr)
    tb=[False]*(10**6 + 10)
    ans=0
    for x in c.keys():
        for j in range(x*2,10**6+5,x):
            tb[j]=True
    for x in c.keys():
        if tb[x]==0 and c[x]==1:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

int main(){
  int n,x,i;
  cin>>n>>x;
  int m[n];
  for(i=0;i<n;i++)cin>>m[i];
  for(i=0;i<n;i++){
    x-=m[i];
  }
  int mi=m[0];
  for(i=1;i<n;i++){
    mi=min(m[i],mi);
  }
  cout<<n+x/mi;
}

Measured memory_bytes: 256
//
// Created by ?????°?????? on 2016/04/15.
//

#include<iostream>
#include <algorithm>

using namespace std;
const int MAX = 2000000;

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest;
    l = 2 * i;
    r = 2 * i +1;

    if (l <= H && A[l] > A[i]){
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> H;
    for (int i = 1; i <= H ; ++i) {
        cin >> A[i];
    }

    for (int i = H ; i >= 1 ; i--) {
        maxHeapify(i);
    }
    for (int i = 1; i <= H ; ++i) {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3116
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n, k;
  cin >> n >> k;
  v p(n, 0);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int sum_price = 0;
  rep(i, k) sum_price += p[i];
  cout << sum_price << endl;
}


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

int main() {
	int N, M;
	std::cin >> N >> M;
	std::vector<int> result(N, 0);
	int a, b;
	for (int i = 0; i < M; i++) {
		std::cin >> a >> b;
		result.at(a - 1)++;
		result.at(b - 1)++;
	}
	for (int i = 0; i < N; i++) {
		std::cout << result.at(i) << std::endl;
	}
	return 0;
}

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

int main(){
  int a;
  cin >> a;
  int b;
  cin >> b;

  b = 2 * b + 1;
  if(a % b == 0){
    cout << a / b << endl;
  }
  else{
    cout << a / b + 1 << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
ans = 0 
for i in range(1,N):
    temp = list(set(S[0:i]))
    temp2 = list(set(S[i:N]))
    temp_ans =0
    for j in range(len(temp)):
        if temp[j] in temp2:
            temp_ans += 1
    if temp_ans>ans:
        # print(temp)
        # print(temp2)
        ans = temp_ans
        # ans2 = i
        # print(i)
print(ans)

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

int main(){
  vector<string> st;
  string s;
  cin>>s;
  int kk;
  cin>>kk;
  int kp=s.size();
  for(int i=1;i<=min(kk,kp);i++){
    for(int j=0;j<=s.size()-i;j++){
      string str(i,'a');
      for(int k=0;k<i;k++){
        str[k]=s[j+k];
      }
      st.push_back(str);
    }
  }
  if(s.size()==1)st.push_back(s);
  sort(st.begin(),st.end());
  unique(st.begin(),st.end());
  //for(int i=0;i<st.size();i++)cout<<st[i]<<endl;
  kk--;
  cout<<st[kk]<<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) { 
        cin >> A[i];
        A[i]--;
    }
    
    vector<int> ans;
    bool judge = true;
    for (int cnt = 0; cnt < N; cnt++) {
        bool del = false;
        for (int i = (int)A.size()-1; i >= 0; i--) {
            if (A[i] == i) {
                del = true;
                ans.push_back(A[i]);
                A.erase(A.begin() + i);
                break;
            }
        }
        if (del == false) { judge = false; break; }
    }
    
    reverse(ans.begin(), ans.end());
    if (judge) {
        for (auto an : ans) cout << an+1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 10

int main()
{
	int i, j, n[N], min, temp;

	for( i=0; i<N; i++ ){
		printf("");
		scanf("%d", &n[i]);
	}

	for( i=0; i<N; i++ ){
		min=i;
		for( j=i+1; j<N; j++ ){
			if( n[j]<n[min] ){
				min=j;
			}
		}
		temp=n[min];
		n[min]=n[i];
		n[i]=temp;
	}
	
	for( j=N-1; j>=7; j-- ){
		printf("%d\n", n[j]);
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int v1 = N % 10;
    N /= 10;
    int v2 = N % 10;
    N /= 10;
    int v3 = N % 10;
    N /= 10;
    int v4 = N % 10;
    
    if (v1 == v2 && v2 == v3 || v2 == v3 && v3 == v4) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

# N = I()
# a = LI()

A, B, C, D = LI()

if B <= C or D <=A:
    ans = 0
elif C <= A and B <= D:
    ans = B - A
elif A<=C and D<=B:
    ans = D - C
elif A<=C and B<=D:
    ans = B-C
elif C<=A and D<=B:
    ans = D-A
else:
    ans = 'error'

print(ans)

Measured memory_bytes: 26976
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++) cin >> vec[i];
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int mini = i;
        for(int j = i + 1; j < N; j++) {
            if(vec[j] < vec[mini]) mini = j;
        }
        if(mini != i) {
            ans++;
            swap(vec[i], vec[mini]);
        }
    }
    for(int i = 0; i < N; i++) {
        cout << vec[i] << "\n "[i < N - 1];
    }
    cout << ans << endl;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Node;
struct S{
  S() : N(0), M(0) {}
  int N, M;
  vector<char> cv;
  vector<Node> G;
};
S input(){
  S s;
  cin >> s.N >> s.M;
  s.cv = vector<char>(s.N);
  REP(i, s.N) cin >> s.cv[i];
  s.G = vector<Node>(s.N);
  REP(i, s.M){
    int a, b; cin >> a >> b;
    s.G[a - 1].push_back(b - 1);
  }
  return s;
}
set<char> infinite(S& s){
  set<char> res;
  bool d[100][100] = {};
  REP(i, s.N)FORIT(e, s.G[i]){
    d[i][*e] = true;
  }
  REP(k, s.N)REP(i, s.N)REP(j, s.N) d[i][j] |= (d[i][k] & d[k][j]);
  REP(i, s.N) if(d[i][i]) res.insert(s.cv[i]);
  return res;
}
int memo[100][100];
int dfs(int u, int v, S& A, S& B){
  if(memo[u][v] != -1) return memo[u][v];
  int& res = memo[u][v];
  res = 0;
  if(A.cv[u] == B.cv[v]){
    FORIT(e1, A.G[u])FORIT(e2, B.G[v]){
      res = max(res, dfs(*e1, *e2, A, B));
    }
    res += 1;
  }else{
    FORIT(e2, B.G[v]){
      res = max(res, dfs(u, *e2, A, B));
    }
    FORIT(e1, A.G[u]){
      res = max(res, dfs(*e1, v, A, B));
    }
    FORIT(e1, A.G[u])FORIT(e2, B.G[v]){
      res = max(res, dfs(*e1, *e2, A, B));
    }
  }
  return res;
}
int solve(S& A, S& B){
  set<char> inf1 = infinite(A);
  set<char> inf2 = infinite(B);
  FORIT(it, inf1)if(inf2.count(*it)) return -1;
  memset(memo, -1, sizeof(memo));
  int ans = 0;
  REP(i, A.N)REP(j, B.N) ans = max(ans, dfs(i, j, A, B));
  return ans;
}
int main(){
    S A = input();
    S B = input();
    cout << solve(A, B) << endl;
  return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
int32_t main()
{
	IOS;
	int a, b, c;
	cin>>a>>b>>c;
	int ans=min(c, b/a);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BGridCompression {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, w;
	    in >> h >> w;
	    vector<vector<char>> a(h, vector<char>(w));
	    for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                in >> a[i][j];
            }
	    }

	    vector<int> col(h, 0);
	    vector<int> row(w, 0);
	    for(int i=0; i<h; i++){
	        for(int j=0; j<w; j++){
	            if(a[i][j] == '#'){
	                col[i] = 1;
	                row[j] = 1;
	            }
	        }
	    }

	    for(int i=0; i<h; i++){
	        if(!col[i]) continue;
	        for(int j=0; j<w; j++){
                if(!row[j]) continue;
                out << a[i][j];
	        }
	        out << endl;
	    }
	}
};


int main() {
	BGridCompression solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

static int gdbi = 0;

void
east(int dice[6])
{
	int t = dice[2];
	dice[2] = dice[0]; /* 3 ??? 1 */
	dice[0] = dice[3]; /* 1 ??? 4 */
	dice[3] = dice[5]; /* 4 ??? 6 */
	dice[5] = t;       /* 6 ??? 3 */
}

void
south(int dice[6])
{
	int t = dice[1];
	dice[1] = dice[0]; /* 2 ??? 1 */
	dice[0] = dice[4]; /* 1 ??? 5 */
	dice[4] = dice[5]; /* 5 ??? 6 */
	dice[5] = t;       /* 6 ??? 2 */
}

void
rotate(int dice[6])
{
	int t = dice[3];
	dice[3] = dice[1]; /* 4 ??? 2 */
	dice[1] = dice[2]; /* 2 ??? 3 */
	dice[2] = dice[4]; /* 3 ??? 5 */
	dice[4] = t;       /* 5 ??? 4 */
}

bool
compare(int dice1[6], int dice2[6])
{
	int u, v;
	int i;

	u = dice1[0];
	v = dice1[1];
	for (i = 0; i < 4; ++i)
	{
		if (dice2[1] == v)
			break;

		south(dice2);
	}

	if (dice2[1] != v) /* dice2[2]????????¢???????????????????????? */
	{
		for (i = 0; i < 4; ++i)
		{
			if (dice2[1] == v) /* dice2[2]????????¢??? */
				break;

			rotate(dice2);
		}
	}

	if (dice2[1] != v)
		return false;

	for (i = 0; i < 4; ++i)
	{
		if (dice2[0] == u) /* dice2[1]????????¢??? */
			break;

		east(dice2);
	}

	for (i = 0; i < 6; ++i)
	{
		if (dice1[i] != dice2[i])
			break;
	}

	if (i == 6)
		return true;
	else
		return false;
}

bool
solve(int dice[100][6], int n)
{
	int i, j;

	for (i = 0; i < n - 1; ++i)
	{
		for (j = i + 1; j < n; ++j)
		{
			if (i == 0 && j == 30)
				gdbi++;

			if (compare(dice[i], dice[j]))
				return false;
		}
	}

	return true;
}

int
main(int argc, char** argv)
{
	int dice[100][6];
	int n;
	int i, j;

	scanf("%d\n", &n);
	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < 6; ++j)
			scanf("%d", &dice[i][j]);
	}

	printf("%s\n", solve(dice, n) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 584
fun main(args: Array<String>) = panasonic2020c()

fun panasonic2020c() {
    val (a, b, c) = readLine()!!.split(' ').map { it.toLong() }

    val n = c - a - b

    val answer = if (n > 0 && 4 * a * b < n * n) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 38176
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;

int a[maxn];
bool mark[maxn];

bool ok (int x) {
    while (x % 2 == 0)
        x /= 2;
    while (x % 3 == 0)
        x /= 3;
    return (x == 1);
}

int main() {
    ios_base::sync_with_stdio(false);
    int N = 30000;
    int n;
    cin >> n;
    if (n == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
  cout << 2 << " " << 3 << " " << 4 << " " << 9 << " ";
    n -= 4;
    for (int i = 4; n > 1 and 2 * i + 2 <= N; i += 3) {
      cout << i * 2 << " " << 2 * i + 2 << " ";
        n -= 2;
    }
    for (int i = 5; n > 1 and 3 * i <= N; i += 4) {
      cout << 3 * i << " " << 3 * i + 6 << " ";
        n -= 2;
    }
    for (int i = 6; n > 0 and i <= N; i += 6) {
      cout << i << " ";
        n --;
    }
    cout << endl;
}

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

const int Nmax=200010;

int main() {
	int c[3][3];
	for(int i=0;i < 3;i++){
		for(int j=0;j < 3;j++){
			cin >> c[i][j];
		}
	}
	int a1,a2,a3;
	//b1=c[1][1]-a1,b2=c[1][2]-a1,b3=c[1][3]-a1
	//b1=c[2][1]-a2,b2=c[2][2]-a2,b3=c[2][3]-a2
	//b1=c[3][1]-a3,b2=c[3][2]-a3,b3=c[3][3]-a3
	for(int a1=0;a1 <= 100;a1++){
		for(int a2=0;a2 <= 100;a2++){
			for(int a3=0;a3 <= 100;a3++){
				if(c[0][0]-a1 == c[1][0]-a2 && c[1][0]-a2 == c[2][0]-a3 && c[2][0]-a3 == c[0][0]-a1)
					if(c[0][1]-a1 == c[1][1]-a2 && c[1][1]-a2 == c[2][1]-a3 && c[2][1]-a3 == c[0][1]-a1)
						if(c[0][2]-a1 == c[1][2]-a2 && c[1][2]-a2 == c[2][2]-a3 && c[2][2]-a3 == c[0][2]-a1){
							cout << "Yes" << endl;
							return 0;
						}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
	int l;
	double ans;
	cin >> l;
	double length = (double)(l)/3;
	ans = length*length*length;
	cout << setprecision(12) << fixed << ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}


int main() {
    ll x;
    cin >> x;

    if(x > 99991){
        cout << 100003 << endl;
        return 0;
    }

    for(ll i = x; i <= 100000; i++){
        if(is_prime(i)){
            cout << i << endl;
            break;
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <complex>
#define rep(i, j, n) for (int i = (j); i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; i >= (j); --i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

int n, m, a, b;
vector<int> g[1010];

int main()
{
  int n, m;
  cin >> n >> m;
  rep(i, 0, m)
  {
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
  }

  ll ans = INF;
  vector<int> out;

  rep(i, 0, n)
  {
    // i スタートの最小のサイクル
    vector<int> prev(n, -1);
    vector<bool> seen(n, false);
    queue<int> q;
    bool cycle = false;
    q.push(i);
    while (q.size())
    {
      int v = q.front();
      q.pop();
      for (int nv : g[v])
      {
        if (nv == i)
        {
          prev[i] = v;
          cycle = true;
          break;
        }
        if (!seen[nv])
        {
          seen[nv] = true;
          prev[nv] = v;
          q.push(nv);
        }
      }
      if (cycle)
        break;
    }

    if (cycle)
    {
      int j = i;
      vector<int> tmp;
      while (prev[j] != i)
      {
        tmp.push_back(j);
        j = prev[j];
      }
      tmp.push_back(j);

      if ((int)tmp.size() < ans)
      {
        ans = (int)tmp.size();
        out = tmp;
      }
    }
  }

  if (ans == INF)
    cout << -1 << endl;
  else
  {
    cout << out.size() << '\n';
    for (int o : out)
      cout << o + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

template <class RandomIt>
auto rsort(RandomIt first, RandomIt last)
  -> typename std::enable_if<std::is_integral<
    typename RandomIt::value_type::first_type>::value>::type
{
  using PairType = typename RandomIt::value_type;
  using KeyType = typename PairType::first_type;

  intmax_t cur_shift=0, max_exp=sizeof(KeyType);
  std::vector<PairType> work(last-first);
  for (int i=0; i<max_exp; ++i) {
    size_t num[256]={};

    for (RandomIt it=first; it<last; ++it)
      ++num[((it->first)>>cur_shift)&255];

    {
      size_t tmp=0;
      for (int j=0; j<256; ++j)
        std::swap(tmp, num[j]+=tmp);
    }

    for (RandomIt it=first; it<last; ++it)
      work[num[((it->first)>>cur_shift)&255]++] = *it;

    {
      size_t j=0;
      for (RandomIt it=first; it<last; ++it)
        *it = work[j++];
    }

    cur_shift += 8;
  }

  if (!std::is_signed<KeyType>::value) return;

  RandomIt mid=last;
  for (RandomIt it=last; --it>=first;)
    if ((it->first) >= 0) {
      mid = ++it;
      break;
    }

  if (mid == last)
    return;

  std::copy(first, mid, work.begin()+(last-mid));
  std::copy(mid, last, work.begin());
  std::copy(work.begin(), work.end(), first);
}

int main() {
  size_t W, H;
  scanf("%zu %zu", &W, &H);

  std::vector<std::pair<unsigned, size_t>> es;
  for (size_t j=0; j<H+W; ++j) {
    unsigned p;
    scanf("%u", &p);
    es.emplace_back(p, j);
  }

  rsort(es.begin(), es.end());
  size_t a=W+1, b=H+1;
  uintmax_t res=0;
  for (const auto &e: es) {
    if (e.second < W) {
      res += e.first*b;
      --a;
    } else {
      res += e.first*a;
      --b;
    }
  }

  printf("%ju\n", res);
}


Measured memory_bytes: 7532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

map<int, int> mapchik;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n, m;
	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		mapchik[x]++;
	}
	scanf("%d", &m);
	while(m--) {
		int x;
		scanf("%d", &x);
		mapchik[x]--;
		if (mapchik[x] < 0) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");

	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;

int main()
{
  ll N;
  cin >> N;
  vector<ii> v;
  for (int i=0; i<N; i++) {
    ll a, b; cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(),v.end());
  ll t = v[0].first + v[0].second;
  ll cnt = 0;
  for (int i=1; i<N; i++) {
    if (t > v[i].first-v[i].second) {
      t = min(t, v[i].first+v[i].second);
      cnt++;
    } else {
      t = v[i].first+v[i].second;
    }
  }
  ll cntr = 0;
  ll tr = v[N-1].first - v[N-1].second;
  for (int i=N-2; i>=0; i--) {
    if (tr < v[i].first + v[i].second) {
      tr = max(tr, v[i].first - v[i].second);
      cntr++;
    } else {
      tr = v[i].first - v[i].second;
    }
  }

  cout << N - min(cnt, cntr) << endl;

  return 0;
}


Measured memory_bytes: 2420
def main():
  n = int(input())
  A = input()
  v = 1;
  for a in A.split(' '):
      d = int(a)
      if d == 0:
          print(0)
          return

  for a in A.split(' '):
      d = int(a)
      v *= d
      if (v > 1e18):
          print(-1)
          return
  print(v)

main()


Measured memory_bytes: 19396
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 1e2 + 20;
int a[maxn][maxn];
int t[maxn * maxn], id[maxn * maxn];
bool cmp(int a, int b) {
    return t[a] < t[b];
}
void work() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i];
        id[i] = i;
    }
    sort(id + 1, id + 1 + n, cmp);
    sort(t + 1, t + 1 + n);
    int r = 1, c = 1;
    int flag = 1;
    for (int i = n; i >= 1; --i) {
        while (t[i]--) {
            a[r][c] = id[i];
            c += flag;
            if (c > w) {
                r++;
                c = w;
                flag = -1;
            }
            if (c < 1) {
                r++;
                c = 1;
                flag = 1;
            }
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const LL MOD = 1000000007;

char str[100005];
LL dp[100005][2];

int main() {
	cin >> str;
	int n = strlen(str);
	dp[0][0] = 1;
	REP(i, n) {
		dp[i + 1][1] = (dp[i + 1][1] + 3 * dp[i][1]) % MOD;
		if (str[i] == '0')dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % MOD;
		if (str[i] == '1') {
			dp[i + 1][0] = (dp[i + 1][0] + 2 * dp[i][0]) % MOD;
			dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
		}
	}
	cout << (dp[n][0] + dp[n][1]) % MOD << endl;
	return 0;
}

Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Beginner_Contest_132
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N=Sarray()[0];
            var Ai = Sarray();

            //答え以上なら　偶数個目-、奇数個目＋
            var mid = Ai[0] / 2;
            var min = 0L;
            var max = Ai[0];
            var anss = new long[N];
            while (true)
            {
                anss[0] = mid;
                for (var i = 0; i < N - 1; ++i)
                {
                    anss[i + 1] = Ai[i] - anss[i];
                    
                }
                if (Ai[N - 1] == anss[N-1] + mid)
                {
                    var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                    Console.SetOut(sw);
                    Write($"{anss[0]*2}");
                    for(var i=1;i<N;++i)
                    {
                        Write($" {anss[i]*2}");
                    }
                    Console.Out.Flush();
                    return;
                }
                if (Ai[N - 1] < anss[N-1] + mid)//startを↓に
                {
                    max = mid - 1;
                }
                else//startを↑に
                {
                    min = mid + 1;
                }
                mid = min + (max - min) / 2;
            }
        }
    }
}


Measured memory_bytes: 32092
def main():
    n = int(input())
    h = list(map(int, input().split()))
    # dpテーブル作成,スタート地点のdpテーブルの値は0にする
    dp =[10**5] * n
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min([dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i])])
    print(dp[n-1])

if __name__ == "__main__":
    main()

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

namespace AOJ_console
{
    class _1_5_A
    {
        static void Main()
        {
            while (true)
            {
                var rect = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                if (rect[0] == 0 && rect[1] == 0)
                    break;
                Enumerable.Range(1, rect[0]).Select(x => Enumerable.Range(1, rect[1]).Aggregate("", (str, y) => str += "#").Trim()).ToList().ForEach(x => Console.WriteLine(x));
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9740
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .map { line =>
        val arr = line.split(" ").map(_.toInt)
        (arr(0), arr(1))
      }
      .takeWhile {
        case (0, 0) => false
        case _ => true
      }
      .foreach { case (h, w) =>
        val sb = StringBuilder.newBuilder
        for (y <- 0 until h) {
          for (x <- 0 until w) {
            sb.append('#')
          }
          sb.append('\n')
        }
        sb.append('\n')
        print(sb.toString())
      }
  }
}

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

int main() {
  string c;
  cin>>c;
  if(c=="a"){
    cout<<"b"<<endl;
  }
  else if(c=="b"){
    cout<<"c"<<endl;
  }
  else if(c=="c"){
    cout<<"d"<<endl;
  }
  else if(c=="d"){
    cout<<"e"<<endl;
  }
  else if(c=="e"){
    cout<<"f"<<endl;
  }
  else if(c=="f"){
    cout<<"g"<<endl;
  }
  else if(c=="g"){
    cout<<"h"<<endl;
  }
  else if(c=="h"){
    cout<<"i"<<endl;
  }
  else if(c=="i"){
    cout<<"j"<<endl;
  }
  else if(c=="j"){
    cout<<"k"<<endl;
  }
  else if(c=="k"){
    cout<<"l"<<endl;
  }
  else if(c=="l"){
    cout<<"m"<<endl;
  }
  else if(c=="m"){
    cout<<"n"<<endl;
  }
  else if(c=="n"){
    cout<<"o"<<endl;
  }
  else if(c=="o"){
    cout<<"p"<<endl;
  }
  else if(c=="p"){
    cout<<"q"<<endl;
  }
  else if(c=="q"){
    cout<<"r"<<endl;
  }
  else if(c=="r"){
    cout<<"s"<<endl;
  }
  else if(c=="s"){
    cout<<"t"<<endl;
  }
  else if(c=="t"){
    cout<<"u"<<endl;
  }
  else if(c=="u"){
    cout<<"v"<<endl;
  }
  else if(c=="v"){
    cout<<"x"<<endl;
  }
  else if(c=="x"){
    cout<<"y"<<endl;
  }
  else if(c=="y"){
    cout<<"z"<<endl;
  }
  
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h,w;
    cin >> h >> w;
    vector<string> s(h);
    for(i = 0;i < h;++i){
        cin >> s.at(i);
    }
    vector<vector<ll>> visit(h,vector<ll>(w,0));
    ll ans = 0;
    ll di[4] = {0,-1,1,0};
    ll dj[4] = {-1,0,0,1};
    for(i = 0;i < h;++i){
        rep(j,w){
            if(visit.at(i).at(j)) continue;
            ll white = 0, black = 0;
            queue<pair<ll,ll>> que;
            pair<ll,ll>  top = make_pair(i,j);
            visit.at(i).at(j) = true;
            que.emplace(top);
            while(!que.empty()){
                pair<ll,ll>  now = que.front();
                que.pop();
                bool wflag;
                ll ii = now.first;
                ll jj = now.second;
                if(s.at(ii).at(jj) == '.'){
                    wflag = true;
                    ++white;
                }
                else{
                    wflag = false;
                    ++black;
                }
                ll k;
                rep(k,4){
                    ll ni = ii + di[k];
                    ll nj = jj + dj[k];
                    if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                    if(visit.at(ni).at(nj)) continue;
                    if(wflag){
                        if(s.at(ni).at(nj) == '.') continue;
                        visit.at(ni).at(nj) = true;
                        que.emplace(ni,nj);
                    }else{
                        if(s.at(ni).at(nj) == '#') continue;
                        visit.at(ni).at(nj) = true;
                        que.emplace(ni,nj);
                    }
                }
            }
            ans += white*black;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x) {
	return(x + 9) / 10 * 10;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (B / A >= C) {
		cout << C;
	}
	else {
		cout << B / A;
	}
}

Measured memory_bytes: 256
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var n2 = (int)Math.Sqrt(n + 1);
        var ret = 999999999;
        for (int i = 1; i <= n2; i++)
            if (n % i == 0) ret = Math.Min(ret, getF(i, n / i));
        Console.WriteLine(ret);
    }
    public static int getF(int a, long b)
    {
        var wa = a.ToString().Length;
        var wb = b.ToString().Length;
        if (wa >= wb) return wa;
        else return wb;
    }
}

Measured memory_bytes: 13268
N = int(input())
A = list(map(int,input().split()))
X = [0] * (10 ** 5 + 1)
wa = 0
for i in range (N):
    X[A[i]] += 1
    wa += A[i]
Q = int(input())
for i in range(Q):
    b,c = map(int,input().split())
    wa = wa + X[b] * (c - b)
    print(wa)
    X[c] += X[b]
    X[b] = 0

Measured memory_bytes: 20872