akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 500001;
int a[MAX], bit[MAX];

struct Query 
{ 
    int l, r, idx; 
}; 
Query queries[MAX];
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 

void update(int idx, int val, int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 

 
int query(int idx, int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 

void answeringQueries(int n, int q) 
{ 

    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        if (last_visit[a[i]] !=-1) 
            update (last_visit[a[i]] + 1, -1, n); 

        last_visit[a[i]] = i; 
        update(i + 1, 1, n); 

        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                    query(queries[query_counter].r + 1, n)- 
                    query(queries[query_counter].l, n); 
            query_counter++; 
        } 
    } 

    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

int main() 
{ 
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < q; i++) {
        cin >> queries[i].l >> queries[i].r;
        queries[i].l--;
        queries[i].r--;
        queries[i].idx = i;
    }
    sort(queries, queries + q, cmp);
    answeringQueries(n, q);
    return 0; 
} 

Measured memory_bytes: 17424
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  map<int,int> ma[2];
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    ma[0][k]++;
  }
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    ma[1][k]++;
  }
  for(auto p:ma[1]){
    if(ma[0][p.first]<p.second){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 25216
package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	var length int
	if scanner.Scan() {
		n := scanner.Text()
		length, _ = strconv.Atoi(n)
		if length == 1 {
			fmt.Println(1)
			return
		}
	}

	scanner.Scan()
	h := scanner.Text()
	slice := strings.Split(h, " ")
	heights := make([]int, len(slice))

	for i, j := range slice {
		heights[i], _ = strconv.Atoi(j)
	}

	var ng int
	for i := 1; i < length; i++ {
		for j := 0; j < i; j++ {
			if heights[i] < heights[j] {
				ng++
				break
			}
		}
	}
	fmt.Println(length - ng)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii;
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int n;
  while(cin>>n,n!=-1){
    int sum = 0 ;
    if(n <= 10)sum = 1150 ;
    else if(n <= 20)sum += 1150 + (n-10) * 125;
    else if(n <= 30)sum += 1150 + 1250 + (n-20) * 140;
    else sum += 1150 + 1250 + 1400 + (n-30) * 160;

    cout<<4280-sum<<endl;

  }
}

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

int main(){
  int A, B;
  cin >> A >> B;
  int count = 0;
  for (int i = A; i <= B; i++){
    int n1, n2, n4, n5;
    n1 = i % 10;
    n2 = (i % 100 - n1) / 10;
    n5 = i / 10000;
    n4 = i / 1000 - n5 * 10;
    if (n1 == n5 && n2 == n4)
      count ++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
s = input()
n = len( s )

def dfs( i : int, total : int, formular : str  ):
    if i == n - 1:
        if total == 7:
            print( formular+"=7" )
            exit()
    else:
        next = s[ i + 1]
        dfs( i + 1, total + int( next ), formular + "+" + next )
        dfs( i + 1, total -  int( next ), formular + "-" + next )

dfs( 0, int( s[0]),  s[0] )

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main(void)
{
	double x,h,s,x1,h1,s1,s2;
	scanf("%lf",&x);
	scanf("%lf",&h);
	while(!(x==0.0 && h==0.0)){
		
		s=sqrt(h*h+x/2*x/2);
		x1=x*x;
		s1=x*s/2*4+x1;
		
		printf("%lf\n",s1);
		scanf("%lf",&x);
		scanf("%lf",&h);
	}
	return 0;
}

Measured memory_bytes: 1072
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
	
		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.printf("%d %d %.5f", a/b, a%b, (double)a/(double)b);
	}
} 

Measured memory_bytes: 17368
program Project1;
                 
{$APPTYPE CONSOLE}
             
uses
  SysUtils,math;
var
  fx,g,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  l:array of Integer;
  //l,l1,l2:int64;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  c1,c2,c3:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(x);
    Readln(a);
    Readln(b);

    Writeln((x-a)mod b);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
import sys
n, k = map(int, input().split())

mod = 10 ** 9 + 7
f = [1]
for i in range(1,2*n+1):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    return f[n] * (pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod) % mod

ans = comb(2*n-1, n)
if n-1 <= k:
    print(ans)
    sys.exit()

j = 0
for i in range(k+1,n)[::-1]:
    ans -= (comb(n,n-i) * comb(i+j,j)) % mod
    ans %= mod
    j += 1

print(ans)
    
    



Measured memory_bytes: 68080
def dfs(now,depth):
    if vis[now]:
        return 0
    if depth==n:
        return 1
    vis[now]=1
    ans=0
    for i in range(n):
        if graph[now][i]:
            ans+=dfs(i,depth+1)
    vis[now]=0
    return ans
n,m=map(int,input().split())
edge=[[int(i) for i in input().split()]for i in range(m)]
graph=[[0 for i in range(n)]for i in range(n)]
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=1
    graph[edge[i][1]-1][edge[i][0]-1]=1
vis=[0]*n
print(dfs(0,1))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  int x[100];

  cin>>n;
  rep(i,0,n) cin>>x[i];

  int ans=inf;
  rep(i,0,101){
    //iは集会の座標
    int tmp=0;
    rep(j,0,n){
      tmp+=pow(i-x[j],2);
    }

    ans=min(ans,tmp);
  }

  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int X , Y;
    cin >> X >> Y;

    string ans = "No";
    for(int kame = 0; kame <=X; kame++){
        int turu = X - kame;
        if (kame * 4 + turu * 2 == Y) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
import copy
n = int(input())

p1 = list(map(int,input().split()))
p2 = copy.copy(p1)
p3 = copy.copy(p1)
p4 = copy.copy(p1)

for i in range(n-1):

    p = list(map(int,input().split()))
    if p1[0]+p1[1] > p[0]+p[1]:
        p1 = copy.copy(p)

    if p4[0]+p4[1] < p[0]+p[1]:
        p4 = copy.copy(p)

    if p2[0]-p2[1] < p[0]-p[1]:
        p2 = copy.copy(p)

    if -p3[0]+p3[1] < -p[0]+p[1]:
        p3 = copy.copy(p)

print(max(p4[0]-p1[0]+p4[1]-p1[1], p2[0]-p3[0]+p3[1]-p2[1]))



Measured memory_bytes: 74296
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AC = 0; var WA = 0; var TLE = 0; var RE = 0;
            for (int i = 0; i < N; i++)
            {
                var result = Console.ReadLine();
                switch (result)
                {
                    case "AC":
                        AC++;
                        break;
                    case "WA":
                        WA++;
                        break;
                    case "TLE":
                        TLE++;
                        break;
                    case "RE":
                        RE++;
                        break;
                }
            }
            Console.WriteLine($"AC x {AC}");
            Console.WriteLine($"WA x {WA}");
            Console.WriteLine($"TLE x {TLE}");
            Console.WriteLine($"RE x {RE}");
        }
    }
}


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

using namespace std;

//#define int long long
#define pb insert
#define all(a) (a).begin(), (a).end()
#define pi pair<int, int>
#define l first
#define r second
#define ld long double

const int maxn = 1e5 + 1;

set<int> g[maxn];
vector<int> f[maxn];
bool oe[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        --u; --v; g[u].pb(v); g[v].pb(u);
    }
    if (m % 2) {
        cout << -1;
        return 0;
    }
    set<pi> st;
    for (int i = 0; i < n; i++)
        st.insert({g[i].size(), i});
    while (!st.empty()) {
        int x = (*st.begin()).second;
        st.erase(st.begin());
        if (g[x].size() == 0)
            continue;
        int u1 = (*g[x].begin());
        st.erase({g[u1].size(), u1});
        g[x].erase(u1); g[u1].erase(x);
        if (oe[x]) {
            f[x].push_back(u1);
            oe[x] ^= 1;
        } else {
            f[u1].push_back(x);
            oe[u1] ^= 1;
        }
        st.insert({g[u1].size(), u1});
        st.insert({g[x].size(), x});
    }
    for (int i = 0; i < n; i++)
        for (auto to : f[i])
            cout << i + 1 << ' ' << to + 1 << '\n';
    return 0;
}


Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n + 1);
    Int ma = 0;
    Int index = 1;
    for (Int i = 1; i <= n; i++) {
        cin >> a[i];
        if (ma < abs(a[i])) {
            ma = abs(a[i]);
            index = i;
        }
    }
    vector<pair<Int, Int>> res;
    for (Int i = 1; i <= n; i++) {
        if (i == index) continue;
        res.emplace_back(index, i);
    }
    if (a[index] > 0) {
        for (Int i = 1; i <= n - 1; i++) {
            res.emplace_back(i, i + 1);
        }
    }
    else if (a[index] < 0) {
        for (Int i = n; i >= 2; i--) {
            res.emplace_back(i, i - 1);
        }
    }
    dump(res.size());
    for (Int i = 0; i < (Int)res.size(); i++) {
        cout << res[i].fi << " " << res[i].se << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j=1;
    cin>>n;
    int a;
    while(n--)
    {
        cin>>a;
          if(a%2==0 && (a%3!=0 && a%5!=0))
        {
            j=0;

        }
    }
    if(j==1){
    cout<<"APPROVED"<<endl;
    }
    else cout<<"DENIED";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = Integer.parseInt(sc.next());
        }

        for(int i=K+1;i<=N;i++){
            if(A[i-K-1]<A[i-1]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}   

Measured memory_bytes: 61256
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a,b=1,n
for i in range(int(n**0.5)+1,-1,-1):
    if n%i==0:
        a,b=i,n//i
        break
print(a-1+b-1 if a!=1 else b-1)

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

const int N = 100;
int n;
long long ans = -1000000000;
long long F[N][10];
long long P[N][11];
int J[10];

void dfs(int s, int x, int k) {
  if (x == 10) {
    if (k == 0 || (k == 1 && s == 1)) return;

    long long sum = 0;
    for (int i = 0; i < n; i ++) {
      int t = 0;
      for (int j = 0; j < 10; j ++) {
        if (F[i][j] && J[j]) t ++;
      }
      sum += P[i][t];
    }
    ans = max(ans, sum);
    return;
  }

  if (x >= 0) J[x] = s;
  dfs(1, x + 1, k + 1);
  dfs(0, x + 1, k);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < 10; j ++) cin >> F[i][j];
  }
  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < 11; j ++) cin >> P[i][j];
  }

  dfs(0, -1, 0);

  cout << ans << endl;
}


Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s,s1;
    cin>>s>>s1;
    string s2="";
    for(int i=0;i<s1.length()-1;i++)
    {
        s2+=s1[i];
    }
    //cout<<s2;
    if(s2==s)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3132
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string str;
	cin >> str;
	if(str[2] == str[3] && str[4] == str[5]) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    long long x = 1;
    long long y = 0;
    for(int i=0; i<n; ++i){
        long long x2 = 0;
        long long y2 = 0;
        if(s[i] == '0'){
            x2 = x;
            y2 = (y * 3) % MOD;
        }
        else{
            x2 = (x * 2) % MOD;
            y2 = (x + y * 3) % MOD;
        }
        x = x2;
        y = y2;
    }
    long long ans = (x + y) % MOD;
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL NN,MM;
  cin >> NN >> MM;

  LL N = (1 << NN) -1;
  LL M = (1 << MM) - 1;

  vector<vector<LL>> vec(N, vector<LL>(M, 0));

  // LL bit = 0b101010101010101010101;

  LL num = 0;
  REP(i, N)
  {
    REP(j,M){
      vec[i][j] = 0;
      LL ii=i;
      LL jj = j;
      while (true)
      {
        if (ii % 2 == 0 && jj % 2 == 0)
        {
          vec[i][j] = 1;
          break;
        }
        if(ii%2==1&&jj%2==1){
          ii /= 2;
          jj /= 2;
          continue;
        }
        break;
      }
      num++;
    }
  }

    // LL sum = 0;
    // LL summ = 0;

    // REP(i,N){
    //   FOR(ii,i+1,N+1){
    //     REP(j,M){
    //       FOR(jj,j+1,M+1){
    //         LL cnt = 0;
    //         FOR(iii, i, ii)
    //         {
    //           FOR(jjj,j,jj){
    //             cnt += vec[iii][jjj];
    //           }
    //         }

    //         summ++;
    //         if (cnt % 2 == 1)
    //         {
    //           sum++;
    //         }
    //       }
    //     }
    //   }
    // }
    
    // cout << sum << endl;
    // cout << summ << endl;
    REP(i,N){
      REP(j,M){
        cout << vec[i][j];
      }
      cout << endl;
    }

}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	int d1, d2, c = 0;
	bool yes = false;

	for (int i = 0; i < n; i++) {
		cin >> d1 >> d2;

		if (d1 == d2)
			c++;
		else
			c = 0;

		// deb(c);

		if (c == 3)
			yes = true;

	}

	cout << (yes ? "Yes" : "No");

	return 0;
}

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

public class Hello{
    public static void Main(){
        string[]array=Console.ReadLine().Split(' ');
        var A=long.Parse(array[0]);
        var B=long.Parse(array[1]);
        var C=long.Parse(array[2]);
        var D=long.Parse(array[3]);
        
        long temp=0;
        long a=C;
        long b=D;
        if(a<b){
            temp=a;
            a=b;
            b=temp;
        }
        
        long r=a%b;
        
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
        }
        
        long E=(C*D)/b;
        
        long num1=B/C-(A-1)/C;
        long num2=B/D-(A-1)/D;
        long num3=B/E-(A-1)/E;
        
        long sum=(B-A+1)-(num1+num2-num3);
        
        Console.WriteLine(sum);
    }
}


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

using namespace std;

int H, W;
int n, m;
string s[105];

int main() {
	cin >> H >> W;
	n = 0;
	for (int i = 0; i < H; ++i) {
		cin >> s[n];
		bool flag = true;
		for (int j = 0; j < W; ++j)
			if (s[n][j] == '#') {
				flag = false;
				break;
			}
		if (!flag) n++;
	}
	m = W;
	for (int i = 0; i < m; ++i) {
		bool flag = true;
		for (int j = 0; j < n; ++j)
			if (s[j][i] == '#') {
				flag = false;
				break;
			}
		if (flag) {
			m--;
			for (int j = 0; j < n; ++j)
				s[j].erase(i, 1);
			--i;
		}
	}
	for (int i = 0; i < n; ++i)
		cout << s[i] << endl;
	return 0;
}

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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long count=0;
    for(long long i=1;i<=sqrt(n);i++){
        for(long long j=i;j<=n/i;j++){
            long long x=j*i;
            if(x>=n) continue;
            if(j!=i){
                count++;
            }
            count++;
        }
    }
    
    cout<<count;
   return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll gcd(int x,int y){
 if(y>x)swap(x,y);
 if(x%y==0) return y;
 else return gcd(x%y,y);
}
int main(){
  ll a,b;
  cin>>a>>b;
  cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
<?php
list($N, $M) = explode(" ", trim(fgets(STDIN)));

$w = array_fill(1, $N + 1, 0);

While ($str = trim(fgets(STDIN))) {
    list($a, $b) = explode(" ", $str);

    $M = max($a, $b);
    $m = min($a, $b);

    $w[$m]++;
    $w[$M]--;
}

$flg = true;

for ($i = 1; $i <= $N; $i++) {
    if ($w[$i] % 2 != 0) {
        $flg = false;
        break;
    }

    $w[$i + 1] += $w[$i];
}

echo $flg ? 'YES' : 'NO';

Measured memory_bytes: 8952
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;
vl x;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; x.resize(n);
    F0R(i,n) cin >> x[i];
    ll numOp = 0;
    F0R(i,n) {
        int y; cin >> y;
        x[i] -= y;
        numOp -= x[i];
    }
    ll two = 0, one = 0;
    F0R(i,n) {
        ll needTwo = 0;
        if (x[i] < 0) needTwo = (-x[i]+1)/2;
        x[i] += needTwo*2; two += needTwo;
        if (x[i]&1) one ++;
    }
    if (max(one,two) <= numOp) {
        cout << "Yes";
    } else cout << "No";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n,d;
LL x,y;
int cnt[1000][1000];
int counter[3][2001][2001];

LL nums(int sp,int x,int y,int z,int w){
  return counter[sp][z][w]+counter[sp][x][y]-counter[sp][x][w]-counter[sp][z][y];
}

bool test(LL len){
  LL a = len/d+1;
  int b = (int)(len%d)+1;
  
  LL mask[3] = {a*a,a*(a-1),(a-1)*(a-1)};
  REP(sp,3){
    REP(i,2*d){
      REP(j,2*d){
	if(cnt[i%d][j%d] > mask[sp])
	  counter[sp][i][j]=1;
	else
	  counter[sp][i][j]=0;
	if(i>0)counter[sp][i][j]+=counter[sp][i-1][j];
	if(j>0)counter[sp][i][j]+=counter[sp][i][j-1];
	if(i>0&&j>0)counter[sp][i][j]-=counter[sp][i-1][j-1];
      }
    }
  }
  /*
  REP(i,2*d){
    REP(j,2*d){
      cerr<<counter[1][i][j]<<" ";
    }
    cerr<<endl;
  }
  REP(i,2*d){
    REP(j,2*d){
      cerr<<counter[2][i][j]<<" ";
    }
    cerr<<endl;
  }
  */
  
  REP(i,d){
    REP(j,d){
      if(nums(0,i,j,i+b,j+b)>0)continue;
      if(nums(1,i+b,j,i+d,j+b)>0)continue;
      if(nums(1,i,j+b,i+b,j+d)>0)continue;
      if(nums(2,i+b,j+b,i+d,j+d)==0){
	return true;
      }
    }
  }
  return false;
}

int solve(){
  LL lb=1,ub=n*d;
  LL mid;
  while(lb<ub){
    mid = (lb+ub)/2;
    if(test(mid)){
      ub=mid;
    }else{
      lb=mid+1;
    }
  }
  return lb;
}

int main(){
  cin>>n>>d;
  REP(i,d){
    REP(j,d)
      cnt[i][j]=0;
  }
  REP(i,n){
    cin>>x>>y;
    cnt[x%d][y%d]+=1;
  }

  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int n, timer = 0, l = 1;
vector<vector<int>> v, up;
vector<int> tin, tout;
vector<ll> d;
map<pair<int, int>, int> data;

void dfs(int u, int p = 1) {
    tin[u] = ++timer;
    up[u][0] = p;
    for (int i = 1; i <= l; i++) {
        up[u][i] = up[up[u][i - 1]][i - 1];
    }
    for (int i = 0; i < v[u].size(); i++) {
        if (v[u][i] != p) {
            d[v[u][i]] = (ll) d[u] + data[{u, v[u][i]}];
            dfs(v[u][i], u);
        }
    }
    tout[u] = ++timer;
}

bool check(int v1, int v2) {
    return tin[v1] <= tin[v2] && tout[v2] <= tout[v1];
}

int lca(int v1, int v2) {
    if (check(v1, v2)) {
        return v1;
    }
    if (check(v2, v1)) {
        return v2;
    }
    for (int i = l; i >= 0; i--) {
        if (!check(up[v1][i], v2)) {
            v1 = up[v1][i];
        }
    }
    return up[v1][0];
}

ll dist(int x, int y) {
    return (ll) d[x] + d[y] - 2 * d[lca(x, y)];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    v.resize(n + 100);
    up.resize(n + 100);
    tin.resize(n + 100);
    tout.resize(n + 100);
    d.resize(n + 100);
    int tmp = n;
    while (tmp) {
        tmp /= 2;
        l++;
    }
    for (int i = 0; i <= n; i++) {
        up[i].resize(l + 1);
    }
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        v[a].push_back(b);
        v[b].push_back(a);
        data[{a, b}] = c;
        data[{b, a}] = c;
    }
    d[1] = 0;
    dfs(1);
    int q, k;
    cin >> q >> k;
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << dist(x, k) + dist(y, k) << endl;
    }
}

Measured memory_bytes: 47104
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	string s;
	cin >> s;

	int iend = s.size();

	for(int i=0;i<iend;i++) {
		s.pop_back();
		if(s.size() % 2 == 0) {
			if(s.substr(0,s.size()/2) == s.substr(s.size()/2, s.size()/2)) break;
		}
	}

	cout << s.size() << endl;
}



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

int main() {
  int N;;
  cin >> N;
  vector<int>L(N);
  for(int i =0;i<N;i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(),L.end());
  int M=0;
  for(int i=0;i<N-1;i++){
    M += L.at(i);
  }
  
  if(L.at(N-1)<M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long int ll;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    char x, y;
    cin >> x >> y;
    if(x < y) {

        cout << "<" << endl;
    }
    else if(x > y) {

        cout << ">" << endl;
    }
    else {
        cout << "=" << endl;
    }
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.Vector as V

import qualified Data.ByteString.Char8 as BS

tuplify2 :: [b] -> (b, b)
tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined
readInt :: BS.ByteString -> Integer
readInt = fst . fromJust . BS.readInteger
readIntTuple :: BS.ByteString -> (Integer, Integer)
readIntTuple = tuplify2 . map readInt . BS.words

getIntTuple :: IO (Integer, Integer)
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples :: Integral a => a -> IO [(Integer, Integer)]
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine

main = do
    (n, m) <- getIntTuple
    edge <- getIntNTuples m
    let edges = edge ++ map swap edge
    let perm = length . filter ((all (flip elem edges)) . makeTuples) . map (1:) . permutations $ [2..n]
    print perm


makeTuples :: [Integer] -> [(Integer, Integer)]
makeTuples (x:y:[]) = [(x, y)]
makeTuples (x:y:ys) = (x, y) : makeTuples (y:ys)

swap :: (a, a) -> (a, a)
swap (x, y) = (y, x)

Measured memory_bytes: 892
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    a, b, c = LI()
    print(max(0, c-(a-b)))
    
main()

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

int int_sort(const void *a, const void *b);
int int_sort2(const void *a, const void *b);
int main(void)
{
    int N, K, i, j=0, A[200000], c[200000],tmp,sum=0;

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

    for (i = 0; i < N;i++){
        c[i] = 0;
    }

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

    qsort(&A, N, sizeof(int), int_sort);
    /*ここまででソート完了*/

    tmp = A[0];
    for (i = 0; i < N; i++)
    {
        if(tmp!=A[i]){
            j++;
            tmp = A[i];
        }
        c[j]++;
    }

    qsort(&c, N, sizeof(int), int_sort2);

    for (i = 0; i < K;i++){
        sum += c[i];
    }

    printf("%d\n", N-sum);

    return 0;
}
int int_sort(const void *a, const void *b)
{
    /* 引数はvoid*型と規定されているのでint型にcastする */
    if (*(int *)a < *(int *)b)
    {
        return -1;
    }
    else if (*(int *)a == *(int *)b)
    {
        return 0;
    }
    return 1;
}
int int_sort2(const void *a, const void *b)
{
    /* 引数はvoid*型と規定されているのでint型にcastする */
    if (*(int *)a < *(int *)b)
    {
        return 1;
    }
    else if (*(int *)a == *(int *)b)
    {
        return 0;
    }
    return -1;
}

Measured memory_bytes: 2556
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    long k = sc.nextLong();
    int j_ = 0;
    for(int j = 0; j < s.length(); j++){
      if(s.charAt(j) != '1'){
        j_ = j;
        break;
      }
    }
    if(j_ >= k){
      System.out.println("1");
    }
    else{
      System.out.println(s.charAt(j_));
    }
  }
}


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

using namespace std;

int main(){

    int H, W;
    cin >> H >> W;

    vector<char> vec((H+2)*(W+2), '#');

    for(int i = 0; i < H; i++){
	for(int j = 0; j < W; j++){
	    char c;
	    cin >> c;
	    vec.at((i+1)*(W+2)+(j+1)) = c;
	}
    }
    
    for(int i = 0; i < H+2; i++){
	for(int j = 0; j < W+2; j++){
	    cout << vec.at(i*(W+2)+j);
	}
	cout << endl;
    }
	    
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep (i, n - 1) {
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    rep (i, n) cout << a[i] << endl;
    
    return 0;
}



Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n;
char s[3003];
int dp[3003],pre[3003],suf[3003];
int main(){
	scanf("%d",&n);
	scanf("%s",s+2);
	dp[1]=pre[1]=suf[1]=1;
	for(int i=2;i<=n;i++){
		if(s[i]=='<')for(int j=1;j<=i;j++)dp[j]=pre[j-1];
		else for(int j=1;j<=i;j++)dp[j]=suf[j];
		for(int j=1;j<=i;j++)pre[j]=(pre[j-1]+dp[j])%mod;
		for(int j=i;j>=1;j--)suf[j]=(suf[j+1]+dp[j])%mod;
	}
	printf("%d\n",pre[n]);
	return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
int main() {
	int n;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int co = 0;
	int now = 0;
	for (int i = 0; i < n; i++) {
		if (now < a[i]) {
			now = a[i];
			co++;
		}
	}
	cout << co << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int cd[3][3];
    rep(i,3){
        rep(j,3){
            cin>>cd[i][j];
        }
    }
    rep(i,101){
        
        int b1,b2,b3;
        b1=cd[0][0]-i;b2=cd[0][1]-i;b3=cd[0][2]-i;
        
        if(b1<0||b2<0||b3<0){cout<<"No"<<endl;return 0;}
        int a2=cd[1][0]-b1;
        if(a2>=0&&(a2==(cd[1][1]-b2))&&(a2==(cd[1][2]-b3))){
            int a3=cd[2][0]-b1;
            if(a3>=0&&(a3==(cd[2][1]-b2))&&(a3==(cd[2][2]-b3))){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        
    }
    
    cout<<"No"<<endl;
    
    return 0;
}


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

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

  int a ; 
  
  for  (a=1 ; a<=10 ; a++){
   if (a*1000 - N >= 0 && (a-1)*1000 - N < 0 ){
       cout << a*1000 - N  << endl;
   }
    
      
  }
   
  
}

Measured memory_bytes: 3620
import heapq

n, m = map(int, input().split())
graph = [[] for i in range(n)]
memo = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

INF = float('inf')

def dijkstra(s):
    dist = [INF for i in range(n)]
    dist[s] = 0
    q = [(0, s, -1)]
    while q:
        cost, node, parent = heapq.heappop(q)
        if dist[node] < cost:
            continue
        if parent != -1:
            memo[parent][node] = 1
        for no, co in graph[node]:
            if dist[node] + co < dist[no]:
                dist[no] = dist[node] + co
                heapq.heappush(q, (dist[node]+co, no, node))

for v in range(n):
    dijkstra(v)

ans = 0
for i in range(n):
    for j in range(n):
        if memo[i][j] == 1:
            ans += 1

print(m - ans//2)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
	
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if((a < b) && (b < c)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] input = sc.next().split("");
		if (input[2].equals(input[3]) && input[4].equals(input[5])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35580
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

typedef unsigned long long ull;

bool sheepWolf(vector<bool> &input, bool first, bool second){
    int N = input.size() - 1 ;
    bool res[N+2];
    res[0] = first;
    res[1] = second;
    for (int i=1;i<N+1;i++){
        if(res[i]){
            if(input[i]){
                res[i+1] = res[i-1];
            }else{
                res[i+1] = !res[i-1];
            }
        }else{
            if(input[i]){
                res[i+1] = !res[i-1];
            }else{
                res[i+1] = res[i-1];
            }
        }
    }
    if (res[0] == res[N] && res[1] == res[N+1]){
        for (int i=0;i<N;i++){
            if(res[i]){
                cout << "S";
            }else{
                cout << "W";
            }
        }
        cout << endl;
        return true;
    }else{
        return false;
    }
}

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<bool> input(N);
    for (int i=0;i<N;i++){
        if(S[i] == 'o') input[i] = true;
        if(S[i] == 'x') input[i] = false;
    }
    input.push_back(input[0]);
    if(!sheepWolf(input, true, true)){
        if(!sheepWolf(input, true, false)){
            if(!sheepWolf(input, false, true)){
                if(!sheepWolf(input, false, false))
                    cout << -1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    let ans = c - std::cmp::min(a - b, c);
    write!(out, "{}\n", ans).unwrap();
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#define ll long long 

using namespace std;
int res = 0;



int main(){
    int n, m; cin >> n >> m;
    int a[m];
    for(int i=0; i<m; i++) cin >> a[i];
    int sum = 0;
    for(int i=0; i<m; i++){
        sum = sum + a[i];
    }
    if(n - sum >= 0) cout << n - sum << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll r;
  std::cin >> r;

  print(3*r*r);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;

	return 0;
}

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

const int n = 1005, M = 1e9 + 7;
int h, w;
string g[n];
int dp[n][n];


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

    cin >> h >> w;
    for (int i = 0; i < h; ++i)
    	cin >> g[i];

    dp[0][0] = 1;

    for (int i = 0; i < h; ++i)
    	for (int j = 0; j < w; ++j)
    		if (i + j == 0 or g[i][j] == '#')
    			continue;
    		else
    		{
    			if (i == 0)
    				dp[i][j] += dp[i][j - 1];
    			else if (j == 0)
    				dp[i][j] += dp[i - 1][j];
    			else
	    			dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % M;
    		}

    cout << dp[h - 1][w - 1] << "\n";

    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 307 , __ = _ << 1 , mo = 1000000007;

int n,nn,m,e[__]={0};
int oc[__]={0};

inline int frees(int l,int r){if(l>r)return 0;return r-l+1-(oc[r]-oc[l-1]);}

lint f[__][__],g[__]={0};

int main()
{
	n=ty(),m=ty(),nn=n+n;
	for(int i=1,a,b;i<=m;i++)a=ty(),b=ty(),e[a]=b,e[b]=a;
	for(int i=1;i<=nn;i++)oc[i]=oc[i-1]+(e[i]>0);

	g[0]=1;
	for(int i=2;i<=nn;i+=2)g[i]=g[i-2]*(i-1)%mo;

	lint ans=0;
	for(int i=1;i<=nn;i++)
		for(int j=i;j<=nn;j++)
		{
			int len=j-i+1;
			if(len&1)continue;
			for(int k=i;k<=j;k++)if(e[k] && (e[k]<i || e[k]>j))goto fail;
			f[i][j]=g[frees(i,j)];
			for(int k=i+1;k<j;k++)f[i][j]=(f[i][j]-f[i][k]*g[frees(k+1,j)]%mo+mo)%mo;
			ans=(ans+g[frees(1,i-1)+frees(j+1,nn)]*f[i][j]%mo)%mo;
		fail:;
		}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#define INFTY 10000000000
int n;
long long int L[500000];
long long int R[500000];
long long int S[500000];
long long int count=0;
void merge(long long int *A,int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int i,j,k;
  int t;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}
void mergesort(long long int *A,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}
int main(){
  int i;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&S[i]);
  mergesort(S,0,n);
  for(i=0;i<n-1;i++)printf("%lld ",S[i]);
  printf("%lld\n",S[i]);
  printf("%lld\n",count);
  return 0;
}

Measured memory_bytes: 12228
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    LLI ans=0;
    int n; cin>>n;
    LLI c; cin>>c;
    if(!c){
        FOR(i,1,n){
            LLI a; cin>>a;
            if(a==c+1){
                ans++;
                c=a;
            }else if(a<=c){
                ans+=a;
                c=a;
            }else{
                ans=-1;
                break;
            }
        }
    }else{
        FOR(i,1,n){
            LLI a; cin>>a;
        }
        ans=-1;
    }
    co(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

void executeCode() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0 ; i < s.length() ; i++) {
		if(s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3816
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 1
d = 0

for i in range(n):
    if d + l[i] <= x:
        d = d + l[i]
        ans = ans + 1
    else:
        break

print(min(ans, n + 1))

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<vector<ll>> v(n,vector<ll>(n));
  rep(i,n)rep(j,n)cin >> v[i][j];
  vector<vector<ll>> w(v);
  rep(k,n)rep(i,n)rep(j,n)w[i][j] = min(w[i][j],w[i][k]+w[k][j]);
  rep(i,n)rep(j,n){
    if(v[i][j] != w[i][j]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll res = 0;
  rep(i,n)for(int j = i+1;j < n;j++)res += v[i][j];
  rep(i,n)for(int j = i+1;j < n;j++){
    rep(k,n){
      if(k == j || k == i)continue;
      if(v[i][k]+v[k][j] == v[i][j]){
        res -= v[i][j];
        break;
      }
    }
  }
  cout << res << endl;
  


  return 0;
}


Measured memory_bytes: 5056