akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

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

    map<int, ll> mp;
    for (ll i = -1000; i <= 1000; i++) {
        ll power = 1;
        rep(j, 5) {
            power *= i;
        }
        mp[i] = power;
    }
    
    for (int i = -1000; i <= 1000; i++) {
        for (int j = i + 1; j <= 1000; j++) {
            if ((mp[j] - mp[i]) == x) {
                cout << j << " " << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <vector>
#include <set>
using namespace std;

void read(int &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
} 

void read(long long &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
}


vector <int> graph[1001];

void addedge(int u,int v)
{
	graph[u].push_back(v);
}

int vis[1001][1001];
struct
{
	int first,second;
}edge[200001];
int mark[1001];
int times=1;
int tmp;

void dfs(int from,int now)
{
	vis[from][now]++;
	mark[now]=times;
	for(auto to:graph[now])
	{
		if(to==from)continue;
		if(vis[from][to]<2&&mark[to]!=times)
		{
			dfs(from,to);
		}
	}
}

int main()
{
//	freopen("sep2_0.in","r",stdin);
//	freopen("sep.out","w",stdout);
	int n,m;
	read(n);read(m);
	for(int i=0;i<m;i++)
	{
		int from,to;
		read(from);read(to);
		addedge(from,to);
		edge[i].first=from;
		edge[i].second=to;
	}
	for(int i=1;i<=n;i++)
	{
		for(auto to:graph[i])
		{
			if(vis[i][to]<2)
			{
				times++;
				dfs(i,to);
			}
		}
	}
	//return 0;
/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cout<<"("<<vis[i][j]<<","<<vis2[i][j]<<")";
		}
		cout<<endl;
	}*/
	for(int i=0;i<m;i++)
	{
		int from=edge[i].first,to=edge[i].second;
		if(vis[to][from])
		{
			if(vis[from][to]>1)
			{
				puts("same");
			}
			else
			{
				puts("diff");
			}
		}
		else
		{
			if(vis[from][to]>1)
			{
				puts("diff");
			}
			else
			{
				puts("same");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 8192
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const int MOD=1000000007;
const double EPS=1e-9;

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


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

    int n_odd = ceil((double)N/2);
    printf("%.10f\n", (double)n_odd/N);

    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool solve(void){
    int h, w, n, sy, sx;
    cin >> h >> w >> n >> sy >> sx;

    string s, t;
    cin >> s >> t;

    vector< vector<int> > l(n, vector<int>(2)), r(n, vector<int>(2)), u(n, vector<int>(2)), d(n, vector<int>(2));
    l[n - 1][1] = 1;
    r[n - 1][1] = w;
    u[n - 1][1] = 1;
    d[n - 1][1] = h;
    for(int i = n - 1 ; i > 0 ; --i){
        l[i][0] = l[i][1] + (s[i] == 'L');
        r[i][0] = r[i][1] - (s[i] == 'R');
        u[i][0] = u[i][1] + (s[i] == 'U');
        d[i][0] = d[i][1] - (s[i] == 'D');

        l[i - 1][1] = max(l[i][0] - (t[i - 1] == 'R'), 1);
        r[i - 1][1] = min(r[i][0] + (t[i - 1] == 'L'), w);
        u[i - 1][1] = max(u[i][0] - (t[i - 1] == 'D'), 1);
        d[i - 1][1] = min(d[i][0] + (t[i - 1] == 'U'), h);
    }
    l[0][0] = l[0][1] + (s[0] == 'L');
    r[0][0] = r[0][1] - (s[0] == 'R');
    u[0][0] = u[0][1] + (s[0] == 'U');
    d[0][0] = d[0][1] - (s[0] == 'D');

    if(sx < l[0][0] || r[0][0] < sx || sy < u[0][0] || d[0][0] < sy){
        return false;
    }

    rep(i, n){
        rep(j, 2){
            if(r[i][j] < l[i][j] || d[i][j] < u[i][j] || r[i][j] <= 0 || w < l[i][j] || d[i][j] <= 0 || h < u[i][j]){
                return false;
            }
        }
    }

    return true;
}

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

    if(solve()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 44440
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
long ans=0;
//入力
String s = sc.next();
//String Builderを用意
StringBuilder sb = new StringBuilder();
//n=文字列長
int n=s.length();
//文字間と末尾に+を挿入→後で消していき計算式として処理
String t="";
for (int i = 0; i < n; i++) {
    t+=Character.toString(s.charAt(i))+"+";
}

for (int i = 0; i < 1<<(n-1); i++) {
    //pはiを二進数表記にした文字列
    String p=Integer.toBinaryString(i);
    //左を0で埋める
    int pl=p.length();
    for (int j = 0; j < n-1-pl; j++) {
        p="0"+p;
    }
    //sbにtを入れる
    sb.append(t);
    //sbからpの0に対応する部分の+を-に置き換える
    for (int j = 0; j < n-1; j++) {
        if(p.charAt(j)=='0'){
            sb.setCharAt(2*j+1, '-');
        }
    }
    //sbをString型にする
    String q=sb.toString();
    //-を消去する
    q=q.replaceAll("-","");
    //ここで計算する　tempは、+が現れるまでの数字部分
    String temp="";
    for (int j = 0; j <q.length(); j++) {
        if(q.charAt(j)=='+'){
            //この部分でなぜかtemp=""(空の文字列)になってしまう……
            //一文字目、q.charAt(0)が'+'になることがあるんですかね？
            //上のif()内の変数jがiになってしまっていた……
            ans+=Long.parseLong(temp);
            //数字を足したので初期化する
            temp="";
        }else{
            temp+=Character.toString(q.charAt(j));
        }
    }
    sb.delete(0, sb.length());
}
//答えの出力
    out.println(ans);
}}

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

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

int main()
{
    char s;
    int count[26] = {0};
    int num;

    //cin >> s はEOFで-1を返すctrl+z
    while ((s = getchar()) != EOF)
    {

        if (s >= 'a' && s <= 'z')
        {
            num = s - 'a';
            count[num]++;
        }
        else if (s >= 'A' && s <= 'Z')
        {
            num = s - 'A';
            count[num]++;
        }
    }

    rep(i, 26)
    {
        printf("%c : %d\n", 'a' + i, count[i]);
    }
    return 0;
}



Measured memory_bytes: 3232
#author: raghav_0901
from math import *

mod = (10**9) + 7


def _in():
    return [int(x) for x in input().split(' ')]


arr = []
MAX = 10**10


def solve(n, m, x, s, skill):

    # check valid
    flag = True
    # print(s, skill)
    for i in skill:
        if i < x:
            flag = False
    if(flag):
        return 0

    if(s == n):
        return MAX

    a2 = solve(n, m, x, s + 1, skill)

    for i in range(m):
        skill[i] = skill[i] + arr[s][i + 1]

    a1 = solve(n, m, x, s + 1, skill) + arr[s][0]

    for i in range(m):
        skill[i] = skill[i] - arr[s][i + 1]

    return min(a1, a2)


def main():
    n, m, x = _in()
    for i in range(n):
        arr.append(_in())
    skill = [0] * (m)
    ans = solve(n, m, x, 0, skill)
    print(ans if ans < MAX else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9288
#include <stdio.h>
#include <math.h>
int main(){
  int n,a,ans=1;
  scanf("%d",&n);
 a = n;
  for(;(a!=4)&&(a!=2)&&(a!=1);ans++){
    if(a%2==0)a=a/2;
    else a=3*a+1;
  };
  printf("%d\n",ans+3);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  rep(i,min(n,k)){
  cout << s[i];
  }   

if(n>k) cout << "..." << endl;

}

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

// N <= 256 = 2^8

int main(){
    int n,m;
    cin >> n >> m;
    set<int> ng;
    rep(i,m){
        int a;
        cin >> a;
        ng.insert(a);
    }

    cout << n - 1 - m << endl;
    return 0;
}


Measured memory_bytes: 3104
s1 = gets.chomp
s2 = gets.chomp

size1 = s1.size
size2 = s2.size
dp = Array.new(size1 + 1){Array.new(size2 + 1, 0)}
dp[0] = (0..size2).to_a
pre = 0
dp.each do |d|
  d[0] = pre
  pre += 1
end

size1.times do |i|
  size2.times do |j|
    prenum = s1[i] == s2[j] ? 0 : 1
    dp[i+1][j+1] = [dp[i+1][j] + 1, dp[i][j+1] + 1, dp[i][j] + prenum].min
  end
end
# dp.each do |d|
#   p d
# end
puts dp[size1][size2]


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

int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cout << A[i] << (i < N - 1 ? " " : "\n");
    }
    for (int i = 1; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while (A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (int k = 0; k < N; k++) {
            cout << A[k] << (k < N - 1 ? " " : "\n");
        }
    }
    return 0;
}

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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        array<array<long, 3>, 3> a;

        for (long i = 0; i < 3; i++) {
            for (long j = 0; j < 3; j++) {
                cin >> a[i][j];
            }
        }
        long n;
        cin >> n;

        while (n--) {
            long x;
            cin >> x;
            for (long i = 0; i < 3; i++) {
                for (long j = 0; j < 3; j++) {
                    if (a[i][j] == x) {
                        a[i][j] = INF;
                    }
                }
            }
        }
        for (long i = 0; i < 3; i++) {
            if (a[i][0] == a[i][1] and a[i][1] == a[i][2] and a[i][2] == INF) {
                puts("Yes");
                return 0;
            }
        }
        for (long j = 0; j < 3; j++) {
            if (a[0][j] == a[1][j] and a[1][j] == a[2][j] and a[2][j] == INF) {
                puts("Yes");
                return 0;
            }
        }
        if (a[0][0] == INF and a[1][1] == INF and a[2][2] == INF) {
            puts("Yes");
            return 0;
        }
        if (a[0][2] == INF and a[1][1] == INF and a[2][0] == INF) {
            puts("Yes");
            return 0;
        }
        puts("No");
    }
}


Measured memory_bytes: 3660
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val tiles: String = sc.nextLine()
    val firstTile: Char = tiles(0) match{
      case '0' => '1'
      case '1' => '0'
    }

    val changeTileNumber: Int = tiles.foldLeft((firstTile, 0)) {
      case ((prevTile: Char, changeNumber: Int), presentTile) => {
        if (prevTile == presentTile) {
          val updatedTile: Char = presentTile match {
            case '0' => '1'
            case '1' => '0'
          }
          (updatedTile, changeNumber + 1)
        } else {
          (presentTile, changeNumber)
        }
      }
    }._2

    println(changeTileNumber)
  }
}

Measured memory_bytes: 33764
#include <bits/stdc++.h>
using namespace std;
 
int N, K;
int l[55];
int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> l[i];
    
    sort(l, l + N, greater<int>());
  
    int toy = 0;
      
      for (int i = 0; i < K; ++i) toy += l[i];
   
  cout << toy << endl;
     
    
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const int mod = 2 * 1e3 + 19;

int main()
{
    int l, r;
    cin >> l >> r;

    if(r - l >= 2019)
    {
        cout << 0 << '\n';
        return 0;
    }

    int najmanji = 2020;

    for(int i = l; i <= r; ++i)
    {
        for(int j = i + 1; j <= r; ++j)
        {
            int izraz = ((i%mod)*(j%mod))%mod;
            najmanji = min(najmanji, izraz);
        }
    }

    cout << najmanji << '\n';

    return 0;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))

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

dic = [{0} for i in range(n)]
for i in range(m):
    a,b = list(map(int,input().split()))
    dic[a-1].add(h[b-1])
    dic[b-1].add(h[a-1])

answer = 0
for i in range(n):
    if h[i] > max(dic[i]):
        answer += 1

print(answer)

Measured memory_bytes: 44216
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long n, result = 0;
    cin >> n;
    map<pair<int, bool>, set<pair<int, bool>>> graph;
    for (int x, y; cin >> x >> y; ) {
        graph[{x, true}].emplace(y, false);
        graph[{y, false}].emplace(x, true);
    }
    set<pair<int, bool>> visited;
    for (auto& p : graph) {
        if (visited.count(p.first) == 0) {
            queue<pair<int, bool>> queue;
            queue.emplace(p.first);
            visited.emplace(p.first);
            long long count[2] = {}, edges = 0;
            do {
                auto& front = queue.front();
                count[front.second]++;
                auto it = graph.find(front);
                edges += it->second.size();
                for (auto& i : it->second) {
                    if (visited.count(i) == 0) {
                        visited.emplace(i);
                        queue.emplace(i);
                    }
                }
                queue.pop();
            } while (!queue.empty());
            result += count[0] * count[1] - edges / 2;
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;

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



  ll ans = 0;
  if(x == 0){
    if(y >= 0) ans = y-x;
    else ans = x - y + 1;
  }
  else if(y == 0){
    if(x<=0) ans = y - x;
    else ans = x - y + 1 ;
  }
  else if(x <= 0 && y <= 0){
    if(y <= x) ans = x - y + 2; //OK
    else ans = y - x; // -3 -1 OK
  }
  else if(x <= 0 && y > 0){
    if(abs(x) >= y) ans = 1 + abs(x) - y;  //-1 2 OK
    else ans = 1 + y - abs(x);//5 -1 OK
  }
  else if(x>=0 && y>=0){
    if(x<=y) ans = y-x; //OK
    else ans = 2 + x- y;// 10 5 OK
  }
  else {
    if(x>=abs(y)) ans = 1 + x-abs(y); //OK
    else ans = 1 + abs(y)-x;// 3 -6 OK
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int m, n_min, n_max;
    cin >> m >> n_min >> n_max;
    if (m == 0 && n_min == 0 && n_max == 0){
      break;
    }
    vector<int> P(m);
    for (int i = 0; i < m; i++){
      cin >> P[i];
    }
    int ans = 0;
    int mx = -1;
    for (int i = n_min; i <= n_max; i++){
      int tmp = P[i - 1] - P[i];
      if (tmp >= mx){
        mx = tmp;
        ans = i;
      }
    }
    cout << ans << endl;
  }
}


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

int gcd(int x, int y){
    int r;
    
    //x>=yにする
    if(x > y) swap(x, y);
    
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    
    cout << gcd(a,b) << endl;
    
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
s = list(input())
allwest = s.count("W")
alleast = n-allwest
left_west = 0
right_east = alleast if s[0] == "W" else alleast-1
answer = left_west + right_east
for i in range(1,n):
    left_west += 1 if s[i-1]=="W" else 0
    right_east -= 1 if s[i] == "E" else 0
    answer = min(answer,left_west+right_east)
print(answer)
    
    



Measured memory_bytes: 5924
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int wf[n+1][n+1];
    rep(i, 0, n+1){
        rep(j, 0, n+1){
            wf[i][j] = 1000000;
            if(i==j){
                wf[i][j] = 0;
            }
        }
    }
    int a[m], b[m], c[m];
    rep(i, 0, m){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        wf[a[i]][b[i]] = c[i];
        wf[b[i]][a[i]] = c[i];
    }
    rep(k, 1, n+1){
        rep(i, 1, n+1){
            rep(j, 1, n+1){
                if(wf[i][j] > wf[i][k] + wf[k][j]){
                    wf[i][j] = wf[i][k] + wf[k][j];
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, m){
        if(wf[a[i]][b[i]] < c[i]){
            ans++;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  --n;
  a=b-a;
  rep(i,n+1){
    ll lb=i*c,ub=i*d;
    lb-=(n-i)*d;
    ub-=(n-i)*c;
    if(lb<=a && a<=ub){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,m;
ll a[100005];
vector< pair<ll,ll> > v;
int main()
{	
	cin>>n>>m;
	ll i;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);

	ll b,c;
	for(i=1;i<=m;i++)
	{
		cin>>b>>c;
		v.pb(mp(c,b));
	}
	sort(all(v));
	reverse(all(v));
	ll j=1;
	for(i=0;i<m;i++)
	{
		//cout<<v[i].ff<<" "<<v[i].ss<<"\n";
		if(a[j]>v[i].ff)
			break;
		while(v[i].ss>0 && j<=n)
		{
			v[i].ss--;
			if(a[j]>v[i].ff)
				break;
			a[j]=v[i].ff;
			j++;
		}
		//cout<<j<<"\n";
		if(j>n)
			break;
	}
	ll sum=0;
	for(i=1;i<=n;i++)
		sum+=a[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  map<vector<int>, int> mp;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> cnt(26);
    string s;
    cin >> s;
    sort(all(s));
    for (auto &x : s)
      cnt[x - 'a']++;
    mp[cnt]++;
  }
  for (auto p : mp) {
    int pp = p.second;
    ans += (pp * (pp - 1)) / 2;
  }
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 33296
package main

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

const (
	MAX_TEXT_SIZE = 1000000
)

func ComputePrefixFunction(pattern string) func(int) int {
	res := make([]int, len(pattern))
	k := 0
	for q := 1; q < len(pattern); q++ {
		for k > 0 && pattern[k] != pattern[q] {
			k = res[k-1]
		}
		if pattern[k] == pattern[q] {
			k += 1
			res[q] = k
		}
	}
	return func(index int) int {
		return res[index]
	}
}

func doMatch(pattern string, f func(int)int, text string) []int {
	res := []int{}
	k := 0
	for i := 0; i < len(text); i++ {
		for k > 0 && pattern[k] != text[i] {
			k = f(k-1)
		}
		if pattern[k] == text[i] {
			k += 1
			if k == len(pattern) {
				res = append(res, i - len(pattern) + 1)
				k = f(k-1)
			}
		}
	}
	return res
}

func Match(pattern string, text string) []int {
	f := ComputePrefixFunction(pattern)
	return doMatch(pattern, f, text)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// original maxTokenSize is not enough
	buffer := make([]byte, MAX_TEXT_SIZE + 1)
	sc.Buffer(buffer, MAX_TEXT_SIZE + 1)

	for {
		b := sc.Scan()
		if !b {
			if sc.Err() != nil && sc.Err() != io.EOF {
				panic(sc.Err())
			}
			break
		}
		text := sc.Text()
		sc.Scan()
		pattern := sc.Text()
		indices := Match(pattern, text)
		stringified := isToAs(indices)
		if len(stringified) > 0 {
			fmt.Println(strings.Join(stringified, "\n"))
		}
	}
}

func isToAs(is []int) []string {
	as := make([]string, len(is))
	for i := 0; i < len(is); i++ {
		as[i] = strconv.Itoa(is[i])
	}
	return as
}


Measured memory_bytes: 54964
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char str1[105];
    char str2[105];
    scanf("%s %s",str1,str2);
    sort(str1,str1+strlen(str1));
    sort(str2,str2+strlen(str2),greater<char>());
    //printf("%s %s\n",str1,str2);
    if(strcmp(str1,str2)<0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	s := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		s[i] = nextInt()
		ans += s[i]
	}

	sort.Ints(s)

	if ans%10 == 0 {
		for i := 0; i < n; i++ {
			if s[i]%10 != 0 {
				ans -= s[i]
				break
			}
		}
	}

	if ans%10 == 0 {
		ans = 0
	}

	fmt.Println(ans)

	// dp := make([]int, n+10)
	// for i := 0; i < n+10; i++ {
	// 	dp[i] = 1000000000
	// }

	// dp[0] = 0
	// for i := 0; i < n; i++ {
	// 	for j := 1; j < n; j++ {
	// 		if dp[i] + s[i]
	// 		chmax(&dp[i+j], )
	// 	}
	// }

	// sum := 0
	// for i := 0; i < n; i++ {
	// 	if (sum+s[i])%10 == 0 {
	// 		continue
	// 	}
	// 	sum += s[i]
	// }
	// ans := 0
	// for bit := uint(0); bit < (1 << uint(n)); bit++ {
	// 	ss := []int{}

	// 	for i := uint(0); i < uint(n); i++ {
	// 		if bit&(1<<i) == 1<<i {
	// 			ss = append(ss, s[i])
	// 		}
	// 	}
	// 	sum := 0
	// 	for i := 0; i < len(ss); i++ {
	// 		sum += ss[i]
	// 	}

	// 	if sum%10 != 0 {
	// 		ans = max(ans, sum)
	// 	}
	// }

	// fmt.Println(ans)

}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
from copy import deepcopy

def main():
    k = int(input())
    l = []
    ll = [1,2,3,4,5,6,7,8,9]

    def dfs(num, keta):
        #print(num,len(num),keta)

        if len(num) == keta:
            ll.append(int(num))
            #print(len(l))

        else:
            if num[-1] == '0':
                dfs(num + '0', keta)
                dfs(num + '1', keta)
            elif num[-1] == '9':
                dfs(num + '9', keta)
                dfs(num + '8', keta)
            else:
                dfs(num + str(int(num[-1]) + 1), keta)
                dfs(num + str(int(num[-1])), keta)
                dfs(num + str(int(num[-1]) - 1), keta)
    for i in range(2,10000):
        l = l + ll
        if len(l) > k:
            l.sort()
            print(l[k-1])
            break
        else:
            tmp_ll = deepcopy(ll)
            ll = []
            for el in tmp_ll:
                dfs(str(el), i)



if __name__ == '__main__':
    main()


Measured memory_bytes: 13868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
    bool ok;
    int c[3][3];
    int a[3],b[3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0;i<=100;i++){
        ok=true;
        b[0]=i;
        b[1]=i-(c[0][0]-c[0][1]);
        b[2]=i-(c[0][0]-c[0][2]);
        a[0]=c[0][0]-b[0];
        a[1]=c[1][0]-b[0];
        a[2]=c[2][0]-b[0];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a[j]+b[k]!=c[j][k]){
                    ok=false;
                }
            }
        }
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int n, k, h[1000000], arr[1000000];
int solve( int idx)
{
    if ( idx == n - 1 )
        return 0;
    if ( arr[idx] != -1 )
        return arr[idx];
    int ans = 2e9;
    for(int i = idx + 1; i < n; i++)
    {
        if ( abs(idx - i) <= k )
            ans = min(ans, abs(h[idx] - h[i]) + solve(i) );
        else
            break;
    }
    arr[idx] = ans;
    return ans;
}
int main()
{
    Hello
    memset(arr, -1, sizeof arr);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}



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

using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;


int main() {
	int N, D; cin >> N >> D;
	cout << (N+2*D) / (2 * D+1) << endl;

}





Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=a*x+b*y
for ab in range(1,max(2*x,2*y)):
    if 2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))<ans:
        ans=2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))
print(ans)

Measured memory_bytes: 3064
n, k = map(int,input().split())
A = list(map(int,input().split()))
nums = {}
for a in A:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1
B = sorted(nums.values())
m = len(B) - k
ans = 0
for i in range(m):
    ans += B[i]
print(ans)

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

std::string s;

int main(){
    INIT;
    cin >> s;
    s[3] = '8';
    cout << s << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)
    cin>>s.at(i);
  vector<int> y={-1,0,1,0};
  vector<int> x={0,1,0,-1};
  bool f=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s.at(i).at(j)=='#'){
        f=0;
        for(int k=0;k<y.size();k++){
          int ik=i+y.at(k);
          int jk=j+x.at(k);
          if(0<=ik&&ik<h&&0<=jk&&jk<w&&s.at(ik).at(jk)=='#')
            f=1;
        }
      }
      if(!f){
        i=h;
        j=w;
      }
    }
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;


    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;
ll p[40];

void init()
{
  p[0] = 1LL;
  for(int i = 1; i < 40; i ++) {
    p[i] = p[i - 1] * 2LL;
  }
}

int main()
{
  ifalse;
  init();
  int n, k;
  cin >> n >> k;

  ld ans = 0;
  for(int i = 1; i <= n; i ++) {
    ll d = i;
    ll cnt = 0;
    while(d < k) {
      cnt ++;
      d *= 2;
    }
    ans += (1.0 / p[cnt]);
  }
  ans *= (1.0 / n);
  prec(15);
  cout <<  ans;
  return 0;
}

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




int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b==c||a+c==b||a==b+c)
		cout << "Yes";
	else
		cout << "No";
	
	
	
	
	
	return 0;
}

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

using namespace std;

int main()
{
    string n; cin >> n;
    int cont = 0;
    for(int i = 0; i < n.size();i++){
       if(n[i]=='?'){n[i]='D';}
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3720
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

s = 0
for i in range(N - 1):
    if A[i] + 1 == A[i + 1]:
        s += C[A[i]-1]
print(s + sum(B))

Measured memory_bytes: 3064
while 1:
    n = input()
    if (n == 0): break
    a = [[0] * n] * n
    for i in range(n):
        a[i] = map(int, raw_input().split())
    
    ans = 0
    for i in range(n):
        c = 0
        for j in range(n):
            if (a[i][j] < a[i][c]):
                c = j
        f = 1
        for i2 in range(n):
            if (a[i2][c] > a[i][c]):
                f = 0
                break
        if f == 1:
            ans = a[i][c]
            break
    print ans

Measured memory_bytes: 6268
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
int main() {
	string S;
	cin >> S;

	ll N = S.size();
	vvvmint dp(N + 1, vvmint(5, vmint(2, 0)));
	dp[0][2][0] = 1;

	repn(i, N){
		if(S[i-1]=='1'||S[i-1]=='?'){
			dp[i][1][0] += dp[i - 1][0][0];
			dp[i][2][0] += dp[i - 1][1][0];
			dp[i][2][1] += dp[i - 1][1][1];
			dp[i][3][1] += dp[i - 1][2][0] + dp[i - 1][2][1];
			dp[i][4][1] += dp[i - 1][3][1] + dp[i - 1][4][1];
		}

		if (S[i - 1] == '0' || S[i - 1] == '?') {
			dp[i][0][0] += dp[i - 1][1][0];
			dp[i][1][0] += dp[i - 1][0][0] + dp[i - 1][2][0];
			dp[i][1][1] += dp[i - 1][2][1];
			dp[i][2][1] += dp[i - 1][3][1] + dp[i - 1][1][1];
			dp[i][4][1] += dp[i - 1][4][1];
		}

		//rep(j, 5)rep(k, 2)cout << i << j << k << " " << dp[i][j][k] << endl;
	}

	cout << dp[N][3][1] + dp[N][4][1] << endl;

}

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

int main(){
  int a,b,anc;
  anc = 0;
  cin >> a >> b;
  if (a >= b){
    anc += a;
    a--;
  }else{
    anc += b;
    b--;
  }
  if (a >= b){
    anc += a;
    a--;
  }else{
    anc += b;
    b--;
  }
  cout << anc;
}

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

int n;
int m[100],a[100],b[100];
vector<int> t;	//時刻の成分(座標圧縮)
vector<int>::iterator it;
int data[200];	//各時刻t[i]における重量の総和をdata[ i ]で表す。

int main(){
	int i;
	while( cin >> n )
	{
		if( n == 0 )
			break;
		for( i = 0;i < n;i++ ){
			cin >> m[i] >> a[i] >> b[i];
			t.push_back( a[i] );
			t.push_back( b[i] );
		}
		sort( t.begin(),t.end() );

		for( i = 1;i < t.size(); ){
			it = lower_bound( t.begin(),t.end(),t[i] );
			it--;
			if( *it == t[i] ){
				it = t.erase( it );
			}
			else{
				i++;
			}
		}

		for( i = 0;i < n;i++ )
		{
			it = lower_bound( t.begin(),t.end(),a[i] );
			data[ it - t.begin() ] += m[i];
			it = lower_bound( t.begin(),t.end(),b[i] );
			data[ it - t.begin() ] -= m[i];
		}

		bool FLAG = true;
		if( data[0] > 150 )
			FLAG = false;
		for( i = 0;i < t.size()-1;i++ ){
			data[i+1] += data[i];
			if( data[i+1] > 150 )
				FLAG = false;
		}
		if( FLAG ){
			cout << "OK\n";
		}
		else{
			cout << "NG\n";
		}

		for( i = 0;i < t.size();i++ ){
			data[i] = 0;
		}
		t.clear();
	}
	return 0;
}

Measured memory_bytes: 1180
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int n, k;
int x1[60], x2[60], y334[60], y2[60], d1[60], d2[60];

vector<LL>x, y, d;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x1[i] >> y334[i] >> d1[i] >> x2[i] >> y2[i] >> d2[i];
		x.emplace_back(x1[i]);
		x.emplace_back(x2[i]);
		y.emplace_back(y334[i]);
		y.emplace_back(y2[i]);
		d.emplace_back(d1[i]);
		d.emplace_back(d2[i]);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	sort(d.begin(), d.end());

	LL ans = 0;
	for (int X = 0; X < x.size() - 1; X++) {
		for (int Y = 0; Y < y.size() - 1; Y++) {
			for (int D = 0; D < d.size() - 1; D++) {
				int count = 0;
				for (int i = 0; i < n; i++) {
					if (x1[i] <= x[X] && x[X + 1] <= x2[i] && y334[i] <= y[Y] && y[Y + 1] <= y2[i] && d1[i] <= d[D] && d[D + 1] <= d2[i]) count++;
				}
				if (count >= k)ans += (x[X + 1] - x[X]) * (y[Y + 1] - y[Y]) * (d[D + 1] - d[D]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    const int n = 100;
    int a, b;
    cin >> a >> b;
    vector<vector<char>> grid(n, vector<char>(n, '.'));
    REP(i, n/2) REP(j, n) grid[i][j] = '#';

    int x = 1, y = 1;
    REP(i, a-1){
        grid[x][y] = '.';
        y += 2;
        if(y > n-2){
            x += 2;
            y = 1;
        }
    }
    x = n/2+1, y = 1; 
    REP(i, b-1){
        grid[x][y] = '#';
        y += 2;
        if(y > n-2){
            x += 2;
            y = 1;
        }
    }

    cout << n << " " << n << endl;
    REP(i, n){
        REP(j, n){
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 998244353;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(0, i, N)
    {
        cin >> A.at(i) >> B.at(i);
    }

    ll ans = 0;
    for (ll i = N - 1; i >= 0; i--)
    {
        if ((A.at(i) + ans) % B.at(i) != 0)
        {
            ans += B.at(i) - (A.at(i) + ans) % B.at(i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4800
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,r,*a = map(int,read().split())


high = a[-1]
delta = -1

for ai in a[::-1]:
    if high < ai:
        high = ai
    if high-ai > delta:
        delta = high-ai

#from collections import Counter
#d = Counter()

high = a[-1]

hs = 0
ls = 0

ans = 0
for ai in a[::-1]:
    if high < ai:
        high = ai
        hs = 1
        ans += min(hs,ls)
        ls = 0
    elif high == ai:
        hs += 1        
    
    if high - ai == delta:
        ls += 1
    

print(ans+min(hs,ls))






Measured memory_bytes: 20544
package main

import "fmt"

func main(){
	var a, b int
	fmt.Scan(&a,&b)
	flag := false

	for i:=1; i*a<=b; i++{
		if a*i == b{
			flag = true
			break
		}
	}

	if flag {
		fmt.Println(a+b)
	} else {
		fmt.Println(b-a)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <set>

using namespace std;

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

    set<int> s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }

    cout << (static_cast<int>(s.size()) == n ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
while 1:
  a,op,b = input().split()
  a = int(a)
  b = int(b)
  if op == "?":
    break
  else:
    if op == "+":
      x = a + b
      print(x)
    elif op == "-":
      x = a - b
      print(x)
    elif op == "*":
      x = a * b
      print(x)
    elif op == "/":
      x = a // b
      print(x)
    else:
      pass


Measured memory_bytes: 5596