akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "k"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=100010;
int n,k;
int f[N],a[N];
int F(int x)
{
    if(x<0) return 1;
    if(f[x]>-1) return f[x];
    f[x]=0;
    forinc(i,1,n) f[x]=max(f[x],1-F(x-a[i]));
    return f[x];
}
main()
{
    fasty;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>n>>k;
    forinc(i,1,n) cin>>a[i];
    reset(f,-1);
    cout<<(F(k) ? "First" : "Second");
}



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

int main(){
  int n,m;
  cin >> n;
  vector<string> b(n);
  for(int i=0; i<n; i++){
    cin >> b.at(i);
  }
  cin >> m;
  vector<string> r(m);
  for(int i=0; i<m; i++){
    cin >> r.at(i);
  }
  
  int max_count = 0;
  int bcount=0, rcount=0;
  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      if(b.at(i) == b.at(j)){
        bcount +=1;
      }
    }
    for(int k=0; k<m; k++){
      if(b.at(i) == r.at(k)){
        rcount +=1;
      }
    }
    int check = bcount - rcount;
    if(max_count < check){
      max_count = check;
    }
    bcount=0;
    rcount=0;
  }
  cout << max_count << endl;
}

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int S, W; cin >> S >> W;

  if(W >= S) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            var gms = new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };

            while ((s = Console.ReadLine()) != null)
            {
                int gmes = 0;
                int gram = int.Parse(s);
                var list = new List<int>();
                int i = 0;

                while (gram != gmes)
                {
                    if (gmes + gms[i] <= gram) { list.Add(gms[i]); gmes += gms[i]; }
                    i++;
                }
                list.Sort();
                foreach (var v in list)
                {
                    Console.Write(v);
                    Console.Write(v != list[list.Count-1] ? ' ' : '\n');
                }
            }
        }
    }
}

Measured memory_bytes: 5780
A, B, C = map(int, input().split())
sum = 0
before = set()
while True:
    if str(A)+' '+str(B)+' '+str(C) in before:
        print(-1)
        exit()
    else:
        before.add(str(A)+' '+str(B)+' '+str(C))
    if A%2==1 or B%2==1 or C%2==1:
        print(sum)
        exit()
    temp1 = int(B/2)+int(C/2)
    temp2 = int(A/2)+int(C/2)
    temp3 = int(A/2)+int(B/2)
    A, B, C = temp1, temp2, temp3
    sum += 1

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

int inputint(void){int n;cin>>n;return n;}
string inputstr(void){string s;cin>>s;return s;}
vector<int> inputvecint(int n){vector<int> vec(n);for(int i=0;i<n;i++)cin>>vec.at(i);return vec;}
vector<string> inputvecstr(int n){vector<string> vec(n);for(int i=0;i<n;i++)cin>>vec.at(i);return vec;}

int main(){
  int N=inputint();
  vector<string> s=inputvecstr(N);
  int M=inputint();
  vector<string> t=inputvecstr(M);

  int maxgain=0;

  for(int i=0;i<N;i++){
    int gain=0;
    for(int j=0;j<N;j++){
      if(s.at(j)==s.at(i)) gain++;
    }
    for(int k=0;k<M;k++){
      if(t.at(k)==s.at(i)) gain--;
    }
    maxgain = max(gain,maxgain);
  }

  cout << maxgain << endl;
  return 0;
}

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

int main(void){
    int a,b;
    cin>>a;
    cin>>b;
    if(a==1){
        if(b==2){
            cout<<"3"<<endl;
        }
        if(b==3){
            cout<<"2"<<endl;
        }
    }
    if(a==2){
        if(b==1){
            cout<<"3"<<endl;
        }
        if(b==3){
            cout<<"1"<<endl;
        }
    }
    if(a==3){
        if(b==2){
            cout<<"1"<<endl;
        }
        if(b==1){
            cout<<"2"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,max,ans;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
	if(d<40){
		d=40;
	}
	if(e<40){
		e=40;
	}
	max=a+b+c+d+e;
	ans=max/5;
	printf("%d\n",ans);
	return 0;
}	


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

int main(){
int max=0,counter=0,m;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
	if(s[i]=='A'){
		m=i;
		if(counter>0)
		break;
	
	for(m;m<s.length();m++){
		if(s[m]=='Z'){
			counter++;
			if(counter>max){
				max=counter;
			    
			}	
		}
		else
		counter++;
		
	}
	
   
}
}
cout<<max;
return 0;
} 


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        String S[] = sc.next().split("");
        String T[] = sc.next().split("");
        
        Arrays.sort(S);
        Arrays.sort(T, Collections.reverseOrder());
        
        String sortedS = String.join("", S);
        String sortedT = String.join("", T);
        
        if( sortedS.equals(sortedT) ){
            System.out.println("No");
            return;
        }
        
        String judge[] = {sortedS, sortedT};
        Arrays.sort(judge);
        
        System.out.println( (judge[0] == sortedS) ? "Yes" : "No" );
        
    }
}


Measured memory_bytes: 35972
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
using namespace std;
typedef long long int ll;

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

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

const ll INF = 1LL << 60;

int main() {
  int N, h[100010];
  ll dp[100010];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];
  for (int i = 0; i < N; i++) dp[i] = INF;
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int visit[4][110][110];
char field[110][110];
int w, h;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll L;

int main() {
  char mapfrom[4] = { 'E', 'S', 'W', 'N' };
  while (scanf("%d %d %lld", &h, &w, &L), w|h|L) {
    int dir;
    int px = -1;
    int py = -1;
    MEMSET(visit, -1);
    REP(y, h) {
      scanf("%s", field[y]);
      REP(x, w) {
        if (field[y][x] == 'E') { dir = 0; }
        if (field[y][x] == 'S') { dir = 1; }
        if (field[y][x] == 'W') { dir = 2; }
        if (field[y][x] == 'N') { dir = 3; }
        if (isalpha(field[y][x])) {
          px = x;
          py = y;
        }
      }
    }
    bool first = true;
    ll turn = 0;
    while (L > turn) {
      if (visit[dir][py][px] != -1 && first) {
        ll cnt = (L - turn) / (turn - visit[dir][py][px]) - 1;
        turn += cnt * (turn - visit[dir][py][px]);
        first = false;
        continue;
      }
      visit[dir][py][px] = turn;
      int nx = px + dx[dir];
      int ny = py + dy[dir];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h || field[ny][nx] == '#') {
        dir = (dir + 1) % 4;
        continue;
      }
      px = nx;
      py = ny;
      turn++;
    }
    printf("%d %d %c\n", py + 1, px + 1, mapfrom[dir]);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, m, a, b, node, dist, parent;
    cin >> n >> m;
    vector<ll> v[n + 1];
    for (ll i = 0; i < m; i++)
    {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll par[n + 1], vis[n + 1];
    fill(par, par + n + 1, infinity);
    fill(vis, vis + n + 1, 0);
    queue<tp> q;
    q.emplace(1, 0, -1);
    vis[1] = 1;
    while (!q.empty())
    {
        tp x = q.front();
        q.pop();
        tie(node, dist, parent) = x;
        if (par[node] == infinity)
            par[node] = parent;
        for (ll i = 0; i < (ll)v[node].size(); i++)
        {
            if (par[v[node][i]] == infinity && vis[v[node][i]] == 0)
            {
                q.emplace(v[node][i], dist + 1, node);
                vis[v[node][i]] = 1;
            }
        }
    }
    for (ll i = 2; i <= n; i++)
    {
        if (par[i] == infinity)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for (ll i = 2; i <= n; i++)
        cout << par[i] << endl;
    return 0;
}

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

int main(){
  int n,flag=0;

  cin>>n;

  char ABC[n];

  for(int i=0; i<n; i++){
    cin>>ABC[i];

    if(ABC[i] == 'C' && ABC[i-1] == 'B' && ABC[i-2] == 'A')
      flag++;
  }

  cout<<flag<<endl;

  return 0;
}

Measured memory_bytes: 256
class Node
  attr_accessor :id, :parent, :left, :right, :sibling, :degree, :height

  def initialize()
    @parent = -1
    @sibling = -1
  end

  def set_info(id, left, right)
    @id = id
    @left = left
    @right = right
    @degree = [@left, @right].select {|c| c != -1}.count
  end

  def set_parent(parent_id)
    @parent = parent_id
  end

  def set_sibling(sibling)
    @sibling = sibling
  end

  def type?
    if @parent == -1
      return 'root'
    elsif @left == -1 && @right == -1
      return 'leaf'
    else
      return 'internal node'
    end
  end

end

n = gets.to_i
$nodes = Array.new(n).map{ Node.new() }
n.times do
  id, left, right = gets.split.map(&:to_i)
  $nodes[id].set_info(id, left, right)
  if left != -1
    $nodes[left].set_parent(id)
    $nodes[left].set_sibling(right)
  end
  if right != -1
    $nodes[right].set_parent(id)
    $nodes[right].set_sibling(left)
  end
end

$result = []
def Preorder(u)
  $result.push(u)
  Preorder($nodes[u].left) if $nodes[u].left != -1
  Preorder($nodes[u].right) if $nodes[u].right != -1
end

def Inorder(u)
  Inorder($nodes[u].left) if $nodes[u].left != -1
  $result.push(u)
  Inorder($nodes[u].right) if $nodes[u].right != -1
end

def Postorder(u)
  Postorder($nodes[u].left) if $nodes[u].left != -1
  Postorder($nodes[u].right) if $nodes[u].right != -1
  $result.push(u)
end

def get_root
  $nodes.each do |n|
    return n.id if n.type? == 'root'
  end
end

root = get_root

puts "Preorder"
Preorder(root)
puts ' ' + $result.join(' ')

$result = []
puts "Inorder"
Inorder(root)
puts ' ' + $result.join(' ')

$result = []
puts "Postorder"
Postorder(root)
puts ' ' + $result.join(' ')



Measured memory_bytes: 8888
#include<iostream>
#include<cstdio>

using namespace std;

void trace(int a[],int n){
	for(int i=0;i<n;i++){
		if(i) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}

void insertsort(int a[],int n){

	for(int i=1;i<n;i++){
		int v=a[i];
		int j=i-1;
		while(j>=0 && v<a[j]){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		trace(a,n);
	}
	return;
}


int main(){
	int n,a[101];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	trace(a,n);
	insertsort(a,n);
	return 0;
}


Measured memory_bytes: 3152
n=int(input())
A=[0]+list(map(int,input().split()))+[0]
cost=0
for i in range(n+1):
    cost+=abs(A[i+1]-A[i])
for i in range(1,n+1):
    if A[i-1]<=A[i]<=A[i+1] or A[i-1]>=A[i]>=A[i+1]:
        print(cost)
    else:
        tmp=min(abs(A[i-1]-A[i]),abs(A[i]-A[i+1]))
        print(cost-2*tmp)

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    string ans="NG";
    for(int i=a;i<=b;i++){
        if(i%k==0)ans="OK";
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3624
N = int(input())
n = [ map(int, input().split()) for i in range(N) ]
kousya = [ [[0]*10 for i in range(3)] for j in range(4) ]
for b, f, r, v in n:
    kousya[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        print('', *kousya[i][j])
    else:
        if i == 3: break
        print('#' * 20)


Measured memory_bytes: 5620
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let (mut c0, mut c1, mut c2, mut c3) = (0u32, 0u32, 0u32, 0u32);

    for _ in 0..n {
        let s: &str = &input.parse::<String>();
        match s {
            "AC" => c0 += 1,
            "WA" => c1 += 1,
            "TLE" => c2 += 1,
            _ => c3 += 1,
        }
    }
    println!("AC x {}", c0);
    println!("WA x {}", c1);
    println!("TLE x {}", c2);
    println!("RE x {}", c3);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  string S, T;
  cin >> S >> T;
  bool flag = S == T;
  for (int i = 0; i < (int)S.length(); i++) {
    rotate(S.begin(), S.begin() + 1, S.end());
    
    if (S == T) {
      flag = true;
      break;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
ll N;
string s;
ll i, j, k, ans = 0, tmp;
int main(){
    ll N, M, A = 0;
    scanf("%lld %lld", &N, &M);
    REP(i,M){
        scanf("%lld", &tmp);
        A += tmp;
    }

    ans = N - A;
    if(ans < 0){
        ans = -1;
    }

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

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

int main() {
  int N;
   cin >> N;
  vector<int> vec(N);
 
  for (int i = 0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  if (vec.at(N/2) == vec.at((N/2)-1)) {
    cout << 0 << endl;
    return 0;
  }
  else {
    cout << vec.at(N/2) - vec.at((N/2)-1) << endl;
  }
}

Measured memory_bytes: 640
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(a, b) + min(c, d);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
S = input()
for i in range(2 ** 3):
    pm = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):  # 下から数えてj番目が1かどうか
            pm[3-1 - j] = "+"
    if eval(S[0]+pm[0]+S[1]+pm[1]+S[2]+pm[2]+S[3]) == 7:
        print(S[0]+pm[0]+S[1]+pm[1]+S[2]+pm[2]+S[3]+"=7")
        exit()

Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007;
const int INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	os << "\n";
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, R;
	cin >> N >> M >> R;

	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}

	vector<vector<int>> d(N, vector<int>(N, INF));
	for (int i = 0; i < N; i++) d[i][i] = 0;
	
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		d[a][b] = c;
		d[b][a] = c;
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {

				if (d[i][k] != INF && d[k][j] != INF) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}

	sort(r.begin(), r.end());
	int ans = INF;
	do {

		int tmp = 0;
		for (int i = 0; i < R - 1; i++) tmp += d[r[i]][r[i + 1]];
		ans = min(ans, tmp);

	} while (next_permutation(r.begin(), r.end()));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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



	cout <<  max(a+b,max(a-b,a*b)) << endl;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin>>S;
    set<char> s;
    rep(i,3)s.insert(S[i]);
    if(s.size() == 1)cout<<No<<endl;
    else cout<<Yes<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define PI 3.14159265358979323846264338327950L
 
int main(){
 
  int a,b;
  int h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);
 
  long double angle =  30*(long double)h + 0.5*(long double)m - (double)m * 6 ;
  long double rad;
    //rad = (angle /180)* M_PI;
 
  //printf("%.10f ",h);
  long double ans = (long double)a*a + (long double)b*b - (long double)(2*a*b)*cosl(angle * (PI / 180));
  printf("%20.20Lf\n",sqrtl(ans));
 
  return 0;
}

Measured memory_bytes: 2576
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e3+4;
const int MOD = 1e9+7;

int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int s;
	cin>>s;
	int dp[s+1]={0};
	dp[0]=1;
	for(int i=1;i<=s;i++)
	{
		for(int j=i;j>=3;j--)
		{
			dp[i]+=dp[i-j];
			dp[i]%=MOD;
		}
	}
	cout<<dp[s]<<"\n";
} 

// nc1*(n-1)c1*9^(n-2)



Measured memory_bytes: 3612
import sys
from collections import deque
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    da = sorted(a,reverse=True)
    if n<=4:
        ans = sum(da[:-1])
        print(ans)
        return
    ans = sum(da[:3])
    idx = 0
    for i in range(4,n):
        if i<6:
            ans += da[i-3]
        elif i<8:
            ans += da[3]
        else:
            if i==8:
                idx = 4
            if i%2:
                idx += 1
            ans += da[i-idx]
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 32368
n=int(input())
a=list(map(int,input().split()))
a.sort()
count=1
ans=0
ans=a[len(a)-1]*count
count+=1
for i in a:
    if ans%i!=0:
        break
ans2=0
for i in a :
    ans2+=ans/i
    
print (ans/ans2)

Measured memory_bytes: 9188
<?php
	fscanf( STDIN, "%d", $n );
	$i = 1;
	do {
		$x = $i;
		if( 0 == $x % 3 || 3 == $x % 10 || FALSE !== strpos( strval( $x ), '3' ) ) {
			print ' '.$i;
		}
	} while( ++$i <= $n );
	print PHP_EOL;
	
	return;
?>

Measured memory_bytes: 6568
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	public void solve() {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int H, W;
		char[][] maze = new char[101][101];

		while (true) {
			String[] tmp = input.nextLine().split(" ");

			H = Integer.parseInt(tmp[0]);
			W = Integer.parseInt(tmp[1]);
			
			if(H == 0 && W == 0) break;

			for (int i = 0; i < H; i++) {				
					maze[i] = input.nextLine().toCharArray();
			}
			
			int ii = 0, jj = 0;
			
			while(maze[ii][jj] != '.' && maze[ii][jj] != 'X') {
				if(maze[ii][jj] == '>') { maze[ii][jj] = 'X'; jj += 1; continue; }
				if(maze[ii][jj] == '<') { maze[ii][jj] = 'X'; jj -= 1; continue; }
				if(maze[ii][jj] == '^') { maze[ii][jj] = 'X'; ii -= 1; continue; }
				if(maze[ii][jj] == 'v') { maze[ii][jj] = 'X'; ii += 1; continue; }
			}		
			if(maze[ii][jj] == 'X') {
				out.println("LOOP");
			} else {
				out.println(jj + " " + ii);
			}
		}
		input.close();
		out.close();
		System.exit(0);
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define sp(x) fixed<<setprecision(x)
#define pb push_back
#define eb emplace_back
#define die(x) return cout << x << endl, 0
#define fastio ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define file ifstream cin("input.txt"); ofstream cout("output.txt")
//#define int long long
//#define endl '\n'

const int MAXN = 300 + 10;
ll d[MAXN][MAXN], dp[MAXN][MAXN];
int32_t main()
{
    fastio;
    ll n , m , x , y , w, l, q;
    cin >> n >> m >> l;
    for(int i = 0 ; i < m ; i++){
        cin >> x >> y >> w;
        x --, y --;
        d[x][y] = d[y][x] = w;
    }
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(i != j && d[i][j] == 0) d[i][j] = INT_MAX;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            for(int k = 0 ; k < n ; k++)
                d[j][k] = min(d[j][k] , d[j][i] + d[i][k]);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
            dp[i][j] = (d[i][j] <= l ? 1 : INT_MAX);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
            for(int k = 0; k < n; k ++)
                dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
    cin >> q;
    while(q --){
        int u, v;
        cin >> u >> v;
        u --, v --;
        cout << (dp[u][v] >= INT_MAX ? -1 : dp[u][v] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

template<typename T>
class SegmentTree{
    int n;
    int realsize;
    T initialvalue;
    vector<T> tree;

    public:
    
    SegmentTree(int size,T initial):realsize(size),initialvalue(initial){
        n = 1;
        while(n < size)n *= 2;

        tree = vector<T>(2*n + 1,initial);
    }

    //1-indexed
    void insert(int i,T data){
        int ind = n+i-1;
        tree[ind] = data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    void add(int i,T data){
        int ind = n+i-1;
        tree[ind] += data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    T get(int l,int r){
        if(l > realsize || r > realsize || l <= 0 || r <= 0)return initialvalue;
        l = n+l-1;
        r = n+r-1;
        if(l == r)return tree[l];
        int prel = l;
        int prer = r;
        T lnum = tree[l];
        T rnum = tree[r];
        l >>= 1;
        r >>= 1;
        while(l != r){
            if(l*2 == prel){
                lnum = lnum + tree[l*2+1];
            }
            if(r*2+1 == prer){
                rnum = rnum + tree[r*2];
            }
            prel = l;
            prer = r;
            l >>= 1;
            r >>= 1;
        }
        return (lnum+rnum);
    }
};

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

    LL n,q;
    cin >> n >> q;

    SegmentTree<LL> st(n,0);
    
    for(int i = 0; i < q; i++){
        LL a,b,c;
        cin >> a >> b >> c;
        if(a == 0){
            st.add(b,c);
        }else{
            cout << st.get(b,c) << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 4956
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long n, p;
	string s;
	long long ans = 0;
	cin >> s;
	n = s.size();
	p = 2019;
	long long co[10000] = { 0 };
	int sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		int c = int(s[i] - '0');
		int x = n - i - 1;
		int a = 10;
		while (x > 0) {
			if ((x & 1) == 1) {
				c = c * a % p;
			}
			a = a * a % p;
			x >>= 1;
		}
		sum = (sum + c) % p;
		co[sum % p]++;
	}
	co[0]++;
	for (int j = 0; j < 10000; j++) {
		ans += co[j] * (co[j] - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3836
import math

a,b,c,d = map(int, input().split())

lcm = int(c*d / math.gcd(c,d))

def num(i):
  ans = b//i - a//i
  if a % i == 0:
    ans +=1
  return ans

lcm_num = num(lcm)

cd_num  = num(c) + num(d)

num = cd_num - lcm_num

print(b-a+1-num)

Measured memory_bytes: 9184
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))

//seg木
int segNUM;	
ll seg[1<<18],*segN;
//まずsegNUM(2べき)を指定
void seguse(int n){if(n==(n&-n)){segNUM=n;segN=seg+segNUM-1;}}
//segN[]で各ノードを初期化してから↓を呼んでその上をまとめて初期化
void seginit(){
	for(int node=segNUM-1;node--;)seg[node]=seg[node*2+1]+seg[node*2+2];//sum
}
//segN[node]をxに更新
void segupdate(int node,ll x){
	node+=segNUM-1;
	seg[node]=x;
	while(node>0){
		node=(node-1)/2;
		seg[node]=seg[node*2+1]+seg[node*2+2];//sum
	}
}
ll subq(int a,int b,int k,int l,int r){
	//seg[k]に[l,r)が対応する
	//disjointな時は単位元を返す
	if(r<=a||b<=l)return 0;//sum

	if(a<=l&&r<=b)return seg[k];//完全に含む
	int left=subq(a,b,k*2+1,l,(l+r)/2),right=subq(a,b,k*2+2,(l+r)/2,r);
	return left+right;//sum
}
//[a,b)に対して答える
ll query(int a,int b){return subq(a,b,0,0,segNUM);}


typedef struct interval{ll l,r;}I;
int hikaku(const void*p,const void*q){
	I pp=*(I*)p,qq=*(I*)q;
	ll pplen=pp.r-pp.l,qqlen=qq.r-qq.l;
	return pplen<qqlen?-1:pplen>qqlen?1:0;
}

I kukan[300010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);

	rep(i,0,n){
		int l,r;
		scanf("%d%d",&l,&r);
		kukan[i].l=l;
		kukan[i].r=r+1;
	}
	qsort(kukan,n,sizeof(I),hikaku);
	

	seguse(1<<17);
	ll icnt=0;//seg木に投げた区間の個数
	/*
	a[i]=seg木に投げた区間のうちiを含むものの個数とし
	segN[1]～segN[k]の和がa[k]になるようにseg木の配列を持つ(imos)
	・[l,r)に1を加える→segN[l]に1、segN[r]に-1を加える
	・a[k]を求める→segNの[0,k+1)の和
	*/
	rep(k,1,m+1){
		while(icnt<n&&kukan[icnt].r-kukan[icnt].l<k){
			//長さk未満の区間をseg木に追加
			segupdate(kukan[icnt].l,segN[kukan[icnt].l]+1);
			segupdate(kukan[icnt].r,segN[kukan[icnt].r]-1);
			icnt++;
		}
		ll ans=n-icnt;
		//(n-icnt)個の区間は、長さがk以上なので必ず回収できる
		//残りのicnt個の区間は、長さがk未満なので高々1度しか訪問しないため、各駅をチェックすれば良い
		repp(x,k,m+1,k)ans+=query(0,x+1);
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main() {
    int N, ans = 0;
    cin >> N;

    for (int n = 1; n <= N; n += 2) {
        int cnt = 0;
        for (int i = 1; i * i < n; ++i) {
            if (!(n % i)) cnt += 2;
        }
        if (cnt == 8) ++ans;
    }

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

Measured memory_bytes: 256
A,B,C = map(int,input().split())

if A == B:
    if A != C and B != C:
        print("Yes")
    else:
        print("No")
elif B == C:
    if A != C and A != B:
        print("Yes")
    else:
        print("No")
elif A == C:
    if B != C and B != A:
        print("Yes")
    else:
        print("No")
        
else:
    print("No")

Measured memory_bytes: 38256
#include<stdio.h>

typedef struct{
  int num;
  char mark;
}trump;


int isStable(trump B[],trump C[], int m){
  int i;
  for(i = 0; i < m; i++){
    if(B[i].mark != C[i].mark)
      return 0;
  }
  return 1;
}

int main(){
  trump A[36],D[36],key;
  int i,j,n,minj,flag;

  scanf("%d%*c",&n);

  for(i = 0; i < n; i++)
    scanf("%c%d%*c",&A[i].mark,&A[i].num);


  for(i = 0; i < n; i++)
    D[i] = A[i];
    
  for(i = 0; i < n; i++){
    minj = i;

    for(j = i; j < n; j++){
      if(A[j].num < A[minj].num)
	minj = j;
    }

    if(i != minj){
      key = A[minj];
      A[minj] = A[i];
      A[i] = key;
    }
  }


  flag = 1;

   while(flag){
    flag = 0;

    for(i = n-1; i > 0; i--){
      if(D[i].num < D[i-1].num){
	key = D[i-1];
	D[i-1] = D[i];
	D[i] = key;
	flag = 1;
      }
    }

  }

   for(i = 0; i < n-1; i++)
     printf("%c%d ",D[i].mark,D[i].num);
   
   printf("%c%d\n",D[n-1].mark,D[n-1].num);
   printf("Stable\n");

  for(i = 0; i < n-1; i++)
      printf("%c%d ",A[i].mark,A[i].num);

      printf("%c%d\n",A[n-1].mark,A[n-1].num);

      if(isStable(A,D,n))
	printf("Stable\n");

      else printf("Not stable\n");
      
  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>
#include<stdlib.h>

int main(){
  int a,b,c;
  int t;

  scanf("%d %d %d", &a, &b, &c);

  t = a; a = b; b = t;
  t = a; a = c; c = t;

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


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define FH 400005
#define inf INT32_MAX
#define MOD 1000000007LL

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pr;


inline void solve()
{
	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	if (a <= 12 && b <= 12 && a > 0 && b > 0)
		cout << "AMBIGUOUS";
	else if (a <= 12 && a > 0)
		cout << "MMYY";
	else if (b <= 12 && b > 0)
		cout << "YYMM";
	else
		cout << "NA";
}



int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int mod = 1e9+7;

int main(){
	map<int, int> b2;
	int N;
	cin >> N;

	ll tmp, bit;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		bit = 1;
		for (int b = 0; b < 60; b++) {
			if (tmp & bit) b2[b]++;
			bit <<= 1;
		}
	}

	ll ans = 0;
	bit = 1;
	for (int b = 0; b < 60; b++) {
		if (b2[b] != 0) ans = (((((bit * b2[b]) % mod) * (N - b2[b])) % mod) + ans) % mod;
		bit = (bit * 2) % mod;
	}

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


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int N, H, W;
int A[10010];
int mapn[110][110];

void rec(int x, int y, int c, int dir){
    if(c >= N){return;}

    mapn[y][x] = c + 1;

    --A[c];
    if(A[c] == 0){++c;}

    int nx = x + dx[dir], ny = y + dy[dir];
    if(nx < 0 || nx >= W || ny < 0 || ny >= H || mapn[ny][nx] != 0){
        dir = (dir + 1) % 4;
        nx = x + dx[dir];
        ny = y + dy[dir];
    }

    rec(nx, ny, c, dir);
}

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

    std::cin >> H >> W >> N;
    
    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    rec(0, 0, 0, 0);

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            std::cout << mapn[i][j] << " \n"[j+1==W];
        }
    }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX 20000
 
typedef struct {
  int data[MAX+2];
  int head, tail;
} Stack;
 
void init(Stack *st) {
  st->head = st->tail = 0;
}
 
void push(Stack *st, int x) {
  if(st->tail == MAX+2) return;
  st->data[(st->tail)++] = x;
}
 
int pop(Stack *st) {
  return st->data[--(st->tail)];
}
 
int empty(Stack *st) {
  return st->head == st->tail;
}
 
int size(Stack *st) {
  return st->tail - st->head;
}
 
int main() {
  char buf[MAX+2];
  int len, ans = 0;  
  Stack st1, st2, st3, st4;
  int cnt = 0;
  int i, j;
   
  scanf("%s", buf);
  len = strlen(buf);
 
  init(&st1);
  init(&st2);
  init(&st3);
  init(&st4);
   
  for(i = 0; i < len; i++) {
    if(buf[i] == '\\') {
      push(&st1, i);
    } else if(buf[i] == '/') {
      if(size(&st1) > 0) {
    int sum = 0;
    j = pop(&st1);
    ans += i - j;
    sum += i - j;
    while(size(&st2) > 0) {
      int top2 = pop(&st2), top3 = pop(&st3);
      if(top2 < j) {
        push(&st2, top2);
        push(&st3, top3);
        break;
      }
      sum += top3;
    }
    push(&st2, j);
    push(&st3, sum);
      }
    }
  }
  while(size(&st3) > 0) {
    push(&st4, pop(&st3));
    cnt++;
  }
  printf("%d\n%d", ans, cnt);    
  for(i = 0; i < cnt; i++) {
    printf(" %d", pop(&st4));
  }
  puts("");
   
  return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
int main(void){
    list<int> lt;
    int n,i,p;
    string s;
    cin>>n;
    if(n==0) return 0;
    for(i=0;i<n;i++){
        cin>>s;
        if(s!="deleteFirst"&&s!="deleteLast") cin>>p;
        if(s=="insert") lt.push_front(p);
        if(s=="delete"){
            list<int>::iterator it;
            for(it=lt.begin();it!=lt.end();it++){
                if((*it)==p){
                    lt.erase(it);
                    break;
                }
            }
        }
        if(s=="deleteFirst") lt.pop_front();
        if(s=="deleteLast") lt.pop_back();
    }
    int tmp=lt.back();
    lt.pop_back();
    for_each(lt.cbegin(), lt.cend(), [](int x){
        cout<<x<<' ';
    });
    cout<<tmp<<'\n';
}


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

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

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

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

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline void finish()
{
  cout << -1 << endl;
  exit(0);
}

int main()
{
  int n;
  cin >> n;
  int a[200010];
  bool one = false;
  rep(i, n)
  {
    cin >> a[i];
    if (a[i] == 1)
      one = true;
  }
  if (!one)
  {
    finish();
  }

  int cnt = 0;
  rep(i, n)
  {
    if (a[i] == cnt + 1)
    {
      cnt++;
    }
  }

  cout << n - cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  s += s;
  vector<vi32> next(26, vi32(s.size()));
  {
    vi32 position(26, -1);
    rrep(i, s.size()) {
      position[s[i] - 'a'] = i + 1;
      rep(j, 26) next[j][i] = position[j] - i;
    }
  }
  i64 acc = 0;
  rep(i, t.size()) {
    int nxt = next[t[i] - 'a'][acc % n];
    if (nxt < 0) {
      cout << -1 << endl;
      return;
    }
    acc += nxt;
  }
  cout << acc << endl;
}


Measured memory_bytes: 21868
import math

def main():
    X = int(input())
    ans = False
    for i in range(X+1):
        mx = 105 * i
        mn = 100 * i
        if mn <= X <= mx:
            ans = True
    if ans:
        print(1)
    else:
        print(0)

if __name__ == "__main__":
    main()

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

int main()
{
    int a, b, count = 0;
    cin >> a >> b;

    for (; a <= b; a++)
    {
        string str = to_string(a);

        if (str[0] == str[4] && str[1] == str[3])
        {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 384
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
MOD = Math.pow(10, 9) + 7 
N = inp.shift() * 1
S = inp.shift()
o = {}
for (i=0; i<N; i++) {
    o[S[i]] = (o[S[i]] || 0) + 1
}
ans = 1
for (var k in o) {
    ans *= o[k] + 1
    ans = ans % MOD
}
console.log(ans - 1)

Measured memory_bytes: 7372
#include<stdio.h>

int main(){
		int n,i,j,k,c=0,ans=0;
		int rl[100000]={1};//l:0
		char s[100003];
		scanf("%d%d%s",&n,&k,s);
		if(s[0]=='R'&&s[1]=='R')ans++;
		for(i=1;i<n;i++){
				if(s[i]=='L'&&s[i-1]=='L')ans++;
				if(s[i+1]=='R'&&s[i]=='R')ans++;
				if(s[i]!=s[i-1])c++;
				rl[c]++;
		}
		if(k>=c)printf("%d\n",n-1);
		else{
				if(ans+k*2>n-1)printf("%d\n",n-1);
				else 
				printf("%d\n",ans+=k*2);
		}
		return 0;
}


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

#define MAX 20
#define INF 1e9
 
int H,W,sx,sy,ans;
int field[MAX][MAX];
const int dx[] = {0,0,-1,1};
const int dy[] = {-1,1,0,0};
 
bool cur(int &x,int &y,int dir,int &g){
    while(true){
	if(0 > x || x >= H || 0 > y || y >= W){
	    return false;
	}
	if(field[x][y] == 1){
	    field[x][y] = 0;
	    x -= dx[dir];
	    y -= dy[dir];
	    return true;
	}
	if(field[x][y] == 3){
	    g = 1;
	    return true;
	}
 
	x += dx[dir];
	y += dy[dir];
    }
}
 
void solve(int x,int y,int cnt){
    if(field[x][y] == 3){
	ans = min(ans,cnt);
	return;
    }
 
    if(cnt == 11){
	return;
    }
 
    for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
 
	if(0 > nx || nx >= H || 0 > ny || ny >= W || field[nx][ny] == 1){
	    continue;
	}
 
	int xx = x, yy = y,g = -1;
	if(cur(xx,yy,i,g)){
	    if(g == 1){
		ans = min(ans,cnt);
		return;
	    }
	    solve(xx,yy,cnt+1);
	    xx += dx[i];
	    yy += dy[i];
	    field[xx][yy] = 1;
	}
    }
  
}
 
int main(){
    while(cin >> W >> H, W | H){
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> field[i][j];
     
		if(field[i][j] == 2){
		    sx = i;
		    sy = j;
		    field[i][j] = 0;
		}
 
	    }
	}
 
	ans = INF;
	solve(sx,sy,1);
 
	if(ans == INF){
	    cout << -1 << endl;
	}else{
	    cout << ans << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3000