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


int n;
vector<int> g[100001];

vector<int> bfs(int x){
    vector<int> dist(n+1,-1);
    queue<int> q;
    q.push(x);
    dist[x] = 0;
    while(!q.empty()){
        int y = q.front();q.pop();

        for(int a: g[y]){
            if(dist[a]==-1){
                dist[a] = dist[y]+1;
                q.push(a);
            }
        }
    }
    return dist;
}

int main(){
    cin>>n;

    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vector<int> b = bfs(1);
    vector<int> w = bfs(n);
    
    int black = 0;
    int white = 0;
    for(int i=1;i<=n;i++){
        if(b[i]<=w[i]) black++;
        else white++;
    }

    if(black>white) cout<<"Fennec";
    else cout<<"Snuke";

}


Measured memory_bytes: 6656
x[8];main(i){float e[2];while(~scanf("%f%f",&e[0],&e[1]))for(i=0;i<2;i++)if(e[i]>=1.1)x[i]++;else if(e[i]>=0.6)x[2+i]++;	else if(e[i]>=0.2)x[4+i]++;else x[6+i]++;for(i=0;i<8;i+=2)printf("%d %d\n",x[i],x[i+1]);exit(0);}

Measured memory_bytes: 0
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

// 試合するペア
alias P = Tuple!(int, "a", int, "b");

int calc(int[][] g) {
    int n = cast(int)g.length;
    // 後ろから popBack するので reverse しておく
    foreach (i; 0..n) g[i].reverse();

    // 対戦可能な試合を v に格納
    void putGame(int i, ref P[] v) {
        if (g[i].length == 0) return;
        int j = g[i][$-1];
        if (g[j].back == i) {
            v ~= P(min(i, j), max(i, j));
        }
    }

    P[] v;
    foreach (i; 0..n) putGame(i, v);

    int day = 0;
    while (v.length > 0) {
        day++;
        v.sort();
        v = v.uniq.array;

        P[] prevV;
        swap(prevV, v);
        foreach (x; prevV) {
            g[x.a].popBack();
            g[x.b].popBack();
        }
        foreach (x; prevV) {
            putGame(x.a, v);
            putGame(x.b, v);
        }
    }
    foreach (i; 0..n) {
        if (g[i].length > 0) return -1;
    }
    return day;
}

void main() {
    int n; scan(n);
    int[][] g;
    for (int i = 0; i < n; i++) {
        g ~= readints.map!(e => e - 1).array;
    }
    writeln(calc(g));
}


Measured memory_bytes: 12540
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,ll> PL;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=1001;

bool reach[MAX_N];
vector<PL> v[MAX_N];
vector<int> rv[MAX_N];
int N,M,cnt=0;
ll d[MAX_N];
ll INFL=1LL<<50;

void search(int to){
  reach[to]=true;
  rep(i,rv[to].size()){
    if(!reach[rv[to][i]]) search(rv[to][i]);
  }
  return ;
}

void bf(){
  rep(i,N) d[i]=-INFL;
  d[0]=0;
  while(true){
    bool update=false;
    rep(i,N){
      rep(j,v[i].size()){
        PL p=v[i][j];
        if(d[i]!=-INFL && (reach[p.first] && d[p.first]<d[i]+p.second)){
          d[p.first]=d[i]+p.second;
          cnt++;
          update=true;
        }
      }
    }
    if(!update) break;
    if(cnt>N) break;
  }
  return ;
}

int main(){
  cin >> N >> M ;
  rep(i,M){
    int a,b; ll c;
    cin >> a >> b >> c ;
    a--; b--;
    v[a].pb(PL(b,c));
    rv[b].pb(a);
  }
  fill(reach,reach+N,false);
  search(N-1);
  //rep(i,N) cout << i << ":" << (reach[i] ? "ok" : "no") << endl;
  bf();
  if(cnt>N) cout << "inf" << endl;
  else cout << d[N-1] << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[200010],n,k;
long long ans; 
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)
	ans+=a[i];
	printf("%lld",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll L, R, d;
        cin >> L >> R >> d;
        cout << (R/d) - (L-1)/d << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;

using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N, ans = 0, x = 0, y = 0, z = 0;
    cin >> N;
    vector <string> s(N);
    int F[10000][2] = {0}, E[10000][2] = {0};
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        //cout << s[i][s[i].size()-1] << endl;
        if (s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') z++;
        else if (s[i][s[i].size()-1] == 'A') x++;
        else if (s[i][0] == 'B') y++;
        for (int j = 0; j < s[i].size()-2; j+=1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') {
                ans++;
            }
        }
    }
    if (z == 0) {
        cout << ans + min(x, y) << endl;
    } else {
        if (x + y == 0) {
            cout << ans + z - 1 << endl;
        } else {
            cout << ans + z + min(x, y) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int main() {
    ll N, M, X, ans = INF;
    cin >> N >> M >> X;
    vi C(N);
    vvi A(N, vi(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    for (int mask = 0; mask < (1 << N); mask++) {
        ll cos = 0;
        vi uds(M);
        for (int i = 0; i < N; i++) {
            if ((mask >> i) & 1) {
                cos+=C[i];
                for (int j = 0; j < M; j++) {
                    uds[j] += A[i][j];
                }
            }
        }
        bool f = true;
        for (int j = 0; j < M; j++) {
            if (uds[j] < X) f = false;
        }
        if (f) ans = min(ans, cos);
    }

    if (ans == INF) ans = -1;
    cout << ans << endl;
}


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


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  if (a < 10 && b < 10) {
    writeln(a * b);
  } else {
    writeln(-1);
  }
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.annotation.tailrec

object Util {
  @tailrec
  def loop(start: Int, end: Int)(f: Int => Unit) {
    if (start < end) {
      f(start)
      loop(start + 1, end)(f)
    }
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    if (n % 2 == 0) {
      println(0.5)
    } else {
      println(((n + 1) / 2).toDouble / n)
    }
  }
}


Measured memory_bytes: 27200
import std.stdio;
import std.string;
import std.conv;
import std.array;

void main() {
	string s;
	string op = "+";
	int res = 0;
	while(1) {
		s = readln();
		int a = to!int(chomp(s));

		if(op[0] == '+')
			res += a;
		else if(op[0] == '-')
			res -= a;
		else if(op[0] == '*')
			res *= a;
		else
			res /= a;

		op = readln();
		if(op[0] == '=')
			break;
	}

	writeln(res);
}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(void){
//  int n,move;
//  cin >> n >>move;
//  int x;
//  while(n--){
//      cin >> x;
//      q.push(x);
//  }
 
//   while(move != 0){
        
//         int cur = q.top();
//         if(cur == 1)break;
//         q.pop();
//         q.push(cur / 2);
//         q.push(cur / 2 + (cur % 2));
//         move--;
//         if(q.top() == 1)break;
        
//     }
//  cout << q.top();
//  cout << " " << 292638192 * 2;
int n;
cin >> n;
if(n % 2 == 0)return cout << -1 ,0;


long long c = 0, cn = 0;

while(c < n)c = c * 10 + 7, cn++;
long long  cnt = 1e6 + 10;

long long sum = c % n;
for(int i = cn;cnt > 0 ;i++,cnt--){
    if(!sum)return cout << i,0;
    sum = (sum * 10 + 7) % n;
    
}
 cout << -1;
}

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

int main()
{
    int arr[3];
    for(int i = 0; i < 3; i++) cin >> arr[i];
    sort(arr, arr+3);
    int res = abs(arr[2] - arr[1]) + abs(arr[1] - arr[0]);
    cout << res << endl;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = list(map(int, input().split()))
i = [i for i in range(1, n+1)]
l = np.array(a) - np.array(i)
b = int(np.median(l))

ans = sum(a)
for i in range(-3, 4):
    ans = min(ans, sum(abs(l-b+i)))

print(ans)


Measured memory_bytes: 34192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    int r = 0;
    bool flag = false;
    REP(i,n){
        cin >> A[i];
        r += A[i];
        if(A[i] >= n) flag = true;
    }
    if(flag == false){
        cout << 0 << endl;
        return 0;
    }
    int l = 0;
    while(l + 1 < r){
        int mid = (l + r) / 2;
        int su = 0;
        REP(i,n){
            if(A[i] - n + 1 + mid <= 0) continue;
            su += (A[i] - n + 1 + mid) / (n+1);
            if( (A[i] - n + 1 + mid) % (n+1) !=0){
                su += 1;
            } 
        }
        if(su > mid) l = mid;
        else r = mid;
    }
    int ans = r;
    REP(i,100000){
        int mid = ( r - i);
        int su = 0;
        REP(i,n){
            if(A[i] - n + 1 + mid <= 0) continue;
            su += (A[i] - n + 1 + mid) / (n+1);
            if( (A[i] - n + 1 + mid) % (n+1) !=0){
                su += 1;
            } 
        }
        if(su > mid) l = mid;
        else ans = mid;
    }
    cout << ans<< endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((c + b - 1) / b <= (a + d - 1) / d ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
#define N 10000
 
int keisan(int);
int main(){
  int i,j,num;
  int S[N];
  int count = 0;
  while(1){
    scanf("%d",&num);
    if(num >= 1 && num <= N)break;
  }
  for(i = 0;i<num;i++){
    scanf("%d", &S[i]);
  }
  for(i = 0;i<num;i++){
    if(keisan(S[i]) == 1)count++;
       }
    printf("%d\n",count);
 
    return 0;
 
  }
int keisan(int a){
  int i;
  if(a==2)return 1;
  if(a < 2 || a%2 == 0)return 0;
  i = 3;
  while(i <= sqrt(a)){
    if(a%i == 0)return 0;
    i = i+2;
  }
  return 1;
}

Measured memory_bytes: 632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		
		int ans = 0;
		for(int i=0; i<3; i++) {
			if(S[i]==T[i])
				ans++;
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <map>
#include <utility>
#include <functional>
using namespace std;

int main() {
	
	map<string, function<int(int, int)>> opMap = {
		make_pair("+", [](int x, int y) { return x + y; }),
		make_pair("-", [](int x, int y) { return x - y; }),
		make_pair("*", [](int x, int y) { return x * y; }),
		make_pair("/", [](int x, int y) { return x / y; }),
	};

	int a, b;
	string op;

	for (;;) {
		cin >> a >> op >> b;
		if (op == "?") {
			break;
		}
		cout << opMap.at(op)(a, b) << endl;
	}
}



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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    string s,t;
    cin >> s >> t;
    vector <int> v[26];
    for (int i = 0; i < s.length(); ++i) {
        v[s[i]-'a'].push_back(i);
    }
    int back = 0;
    int curr = 0;
    if(v[t[0]-'a'].size() == 0){
        printf("-1");
        return 0;
    }
    curr = v[t[0]-'a'][0];
    for (int i = 1; i < t.size(); ++i) {
        if(v[t[i]-'a'].size() == 0){
            printf("-1");
            return 0;
        }
        int index = upper_bound(v[t[i]-'a'].begin() , v[t[i]-'a'].end() , curr) - v[t[i]-'a'].begin();
        if(index != v[t[i]-'a'].size()){
            curr = v[t[i]-'a'][index];
        }
        else{
            back += 1;
            curr = v[t[i]-'a'][0];
        }
    }
    int n = s.size();
    int ans = back*n+curr+1;
    printf("%lld",ans);
    return 0;
}

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

bool comparePair(pair<int, int> a, pair<int, int> b) {
  if(a.first!= b.first) return a.first > b.first;
  else return a.second > b.second;
}

int main() {
  int N, ans=0; cin >> N;
  vector<pair<int, int>> red(N);
  vector<pair<int, int>> blue(N);
  for (int i=0; i<N; i++) cin >> red[i].first >> red[i].second;
  for (int i=0; i<N; i++) cin >> blue[i].first >> blue[i].second;
  sort(red.begin(), red.end(), comparePair);
  sort(blue.begin(), blue.end(), comparePair);
  for (int i=0; i<N; i++) {
    int miny=500,minyidx=0;
    for (int j=0; j<N; j++) {
      if (blue[j].first>red[i].first&&blue[j].second>red[i].second) {
        if (blue[j].second<miny) {miny=blue[j].second; minyidx=j;}
      }
    }
    if(miny<500) {ans++; blue[minyidx].second=-1;}
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
S = str(input())
T = str(input())
count = 0
if (len(S) == 3 and len(T) ==3):
    if (S[0] == "S" or "C" or "R") and (T[0] == "S" or "C" or "R"):
        if (S[0] == T[0]):
            count += 1
    else:print("error")
    if (S[1] == "S" or "C" or "R") and (T[1] == "S" or "C" or "R"):
        if (S[1] == T[1]):
            count += 1
    else:print("error")
    if (S[2] == "S" or "C" or "R") and (T[2] == "S" or "C" or "R"):
        if (S[2] == T[2]):
            count += 1
    else:print("error")
    print(count)
else:print("error")


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

string str;
const string invalid="",undefined="undefined";
string number_memo[51][51],expr_memo[51][51];

string number(const int begin,const int end){
    string& res=number_memo[begin][end];
    if(res!=undefined) return res;

    if(str[begin]=='0'){
        if(end-begin==1) return res="0";
        else return res=invalid;
    }
    res=invalid;
    int pos=begin;
    while(pos!=end and (isdigit(str[pos]) or str[pos]=='?')){
        res+=str[pos]=='?'?'9':str[pos];
        ++pos;
    }
    if(pos!=end) res=invalid;
    return res;
}

string expr(const int begin,const int end){
    string& res=expr_memo[begin][end];
    if(res!=undefined) return res;

    res=number(begin,end);
    if(end-begin<6) return res;
    const char initial=str[begin];
    if((initial!='?' and initial!='L' and initial!='R') or (str[begin+1]!='?' and str[begin+1]!='(') or (str[end-1]!='?' and str[end-1]!=')')) return res;
    rep(i,begin+3,end-2){
        if(str[i]!='?' and str[i]!=',') continue;
        const string tmp1=expr(begin+2,i),tmp2=expr(i+1,end-1);
        if(tmp1==invalid or tmp2==invalid) continue;
        if(initial=='L' or initial=='?'){
            if(tmp1.size()>res.size()) res=tmp1;
            else if(tmp1.size()==res.size()) res=max(res,tmp1);
        }
        if(initial=='R' or initial=='?'){
            if(tmp2.size()>res.size()) res=tmp2;
            else if(tmp2.size()==res.size()) res=max(res,tmp2);
        }
    }
    return res;
}

void solve(){
    fill_n((string*)number_memo,51*51,undefined);
    fill_n((string*)expr_memo,51*51,undefined);
    cin >> str;
    const string ans=expr(0,str.size());
    if(ans==invalid) cout << "invalid" << endl;
    else cout << ans << endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 3324
fn main() {
    let mut sc = new(std::io::stdin());
    let n: usize = sc.next();
    let mut g = vec![vec![(0 as usize, false); n]; n];
    for i in 0..n {
        for j in 0..n {
            g[i][j] = (sc.next(), false);
        }
    }
    let mut ng = false;
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                let d = g[i][k].0 + g[k][j].0;
                if d < g[i][j].0 {
                    ng = true;
                }
                if i != k && k != j && d == g[i][j].0 {
                    g[i][j].1 = true;
                }
            }
        }
    }
    let mut res = 0;
    for i in 0..n {
        for j in 0..n {
            if !g[i][j].1 {
                res += g[i][j].0;
            }
        }
    }
    if ng {
        println!("-1");
    } else {
        println!("{}", res / 2);
    }
}

use std::io;
use std::io::BufRead;

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: ")).unwrap()
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s; cin >> s;


    ll ans = 0LL;
    for(int i=0; i<(1<<(s.size()-1)); i++){
        string tmp = "";
        tmp += s[0];

        for(int j=0; j<s.size()-1; j++){
            if((i&1<<j) != 0){
                tmp += '+';
                tmp += s[j+1];
            }
            else tmp += s[j+1];
        }
        

        ll ad = 0;
        for(int j=0; j<tmp.size(); j++){
            if(tmp[j] == '+'){
                ans += ad;
                
                ad = 0;
            }else{
                ad = 10*ad + (tmp[j]-'0');
                
                if(j == tmp.size()-1) ans += ad;
            }
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Coded by tzc_wk
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
忘文件操作，爆零两行泪。
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read(),s=read(),c[55],d[55];
struct edge{
	int u,v,w;
	edge(){/*ycxakioi*/}
	edge(int _u,int _v,int _w){
		u=_u;v=_v;w=_w;
	}
};
const int MAGIC=2456;
inline int id(int x,int y){
	return x*(MAGIC+1)+y;
}
vector<edge> g[55*2555];
int dist[55*2555],vis[25*2555];
priority_queue<pii,vector<pii>,greater<pii> > q;
signed main(){
	fz(i,1,m){
		int u,v,a,b;cin>>u>>v>>a>>b;
		fz(j,0,MAGIC){
			if(j>=a){
//				cout<<id(u,j)<<endl;
				g[id(u,j)].push_back(edge(id(u,j),id(v,j-a),b));
				g[id(v,j)].push_back(edge(id(v,j),id(u,j-a),b));
			}
		}
	}
	fz(i,1,n)	c[i]=read(),d[i]=read();
	fz(i,1,n){
		fz(j,0,MAGIC-1){
			int cur=j+c[i];
			if(cur>=MAGIC){
				g[id(i,j)].push_back(edge(id(i,j),id(i,MAGIC),d[i]));
			}
			else{
				g[id(i,j)].push_back(edge(id(i,j),id(i,cur),d[i]));
			}
		}
	}
//	cout<<"g[2458].size()="<<g[2458].size()<<endl;
	fillbig(dist);
	dist[id(1,min(s,MAGIC))]=0;
	q.push({0,id(1,min(s,MAGIC))});
	while(!q.empty()){
		pii p=q.top();q.pop();
		int sum=p.fi,x=p.se;
//		cout<<x<<" "<<dist[x]<<endl;
		if(sum>dist[x])	continue;
//		puts("-1");
		foreach(it,g[x]){
			int y=it->v,z=it->w;
//			cout<<"y="<<y<<" "<<z<<endl;
			if(dist[y]>dist[x]+z){
				dist[y]=dist[x]+z;
				q.push({dist[y],y});
			}
		}
	}
	fz(i,2,n){
		int mn=0x3f3f3f3f3f3f3f3fll;
		fz(j,0,MAGIC)	mn=min(mn,dist[id(i,j)]);
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 30340
function main(arg) {
    let [S,T] = arg.split("\n")
    
    let count = 0
    for(let i=0; i<S.length; i++) {
        if(S[i]!==T[i]) {
            count++
        }
    }
    console.log(count)

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32992
#include <stdio.h>

int main()
{
    
    int a;
    int b;
 
    scanf("%d %d",&a,&b);
    
    if(a<b)
    {
        printf("a < b\n");
    }
    else if(a>b)
    {
        printf("a > b\n");
    }
    else if(a==b)
    {
        printf("a == b\n");
    }
   

    return 0;
}

Measured memory_bytes: 580
def d_xor_sum_4(MOD=10**9 + 7):
    N = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    for d in range((len(bin(max(A))) - 2) + 1):
        nonzero = len([1 for a in A if (a >> d) & 1])
        ans += (2**d) * (nonzero) * (N - nonzero)
        ans %= MOD
    return ans

print(d_xor_sum_4())

Measured memory_bytes: 42212
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int H, W;
ll res;
char c[400][400];
pair<pair<int, int>, pair<ll, ll>> g[400][400];

iP t(iP p) {
	if (g[p.first][p.second].first == p)
		return p;
	else
		return t(g[p.first][p.second].first);
}

void u(iP x, iP y) {
	iP X = t(x), Y = t(y);
	if (X != Y) {
		if (g[X.first][X.second].second.first + g[X.first][X.second].second.second > g[Y.first][Y.second].second.first + g[Y.first][Y.second].second.second) {
			g[Y.first][Y.second].first = X;
			g[X.first][X.second].second.first += g[Y.first][Y.second].second.first;
			g[X.first][X.second].second.second += g[Y.first][Y.second].second.second;
		}
		else {
			g[X.first][X.second].first = Y;
			g[Y.first][Y.second].second.first += g[X.first][X.second].second.first;
			g[Y.first][Y.second].second.second += g[X.first][X.second].second.second;
		}
	}
}

int main() {
	cin >> H >> W;
	for (int i = 0; i != H; ++i)
		for (int j = 0; j != W; ++j) {
			cin >> c[i][j];
			g[i][j].first = mkp(i, j);
			if (c[i][j] == '.')g[i][j].second.first = 1;
			else g[i][j].second.second = 1;
		}
	for (int i = 0; i != H - 1; ++i)
		for (int j = 0; j != W; ++j)
			if (c[i][j] != c[i + 1][j])
				u(mkp(i, j), mkp(i + 1, j));
	for (int i = 0; i != H; ++i)
		for (int j = 0; j != W - 1; ++j)
			if (c[i][j] != c[i][j + 1])
				u(mkp(i, j), mkp(i, j + 1));
	for (int i = 0; i != H; ++i) {
		for (int j = 0; j != W; ++j) {
			if (t(mkp(i, j)) == mkp(i, j)) {
				res += g[i][j].second.first*g[i][j].second.second;
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut 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")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:usize,
        ass: [usize;n],
    }
    let mut colors = [0;8];
    let mut top_coder = 0;
    for i in ass.iter(){
        match *i {
            1 ... 399 => colors[0] += 1,
            400 ... 799 => colors[1] += 1,
            800 ... 1199 => colors[2] += 1,
            1200 ... 1599 => colors[3] += 1,
            1600 ... 1999 => colors[4] += 1,
            2000 ... 2399 => colors[5] += 1,
            2400 ... 2799 => colors[6] += 1,
            2800 ... 3199 => colors[7] += 1,
            _ => top_coder += 1
         }
    }
    let mut ans = colors.iter().filter(|x|**x > 0).count();
    if ans == 0 {
        println!("{} {}",1,ans + top_coder);
    }else {
        println!("{} {}",ans,ans + top_coder);
    }

}    


Measured memory_bytes: 4352
n = int(input())
S = ["".join(list(sorted(input()))) for _ in range(n)]
d = {}
for i in S:
    d.setdefault(i, 0)
    d[i] += 1
ans = 0
for value in d.values():
    ans += value * (value - 1) / 2
print(int(ans))

Measured memory_bytes: 19504
#include<stdio.h>

int main(){
  int i,j,s;
  scanf("%d %d",&i,&j);
  s = GCD(i,j);
  printf("%d\n",s);
  return 0;
}

int GCD (int a,int b){
  int c;
  c = a % b;
  if(c == 0) return b;
  GCD(b,c);
  



}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  string S,T;
  cin >> S >> T;
  int len = S.size();
  bool flag = false;
  for(int i = 0; i < len; ++i){
    string tmp = S.substr(i, len-i) + S.substr(0, i);
    if(tmp == T) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    x=input()
    if x=="AC":
        ac+=1
    elif x=="WA":
        wa+=1
    elif x=="TLE":
        tle+=1
    else:
        re+=1
print("AC x "+ str(ac))
print("WA x "+ str(wa))
print("TLE x "+ str(tle))
print("RE x "+ str(re))

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  if(s[k-1] == 'B') s[k-1] = 'b';
  if(s[k-1] == 'C') s[k-1] = 'c';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>vec(3);
    for(int i=0;i<3;i++)cin>>vec[i];
    sort(vec.begin(), vec.end());
    if(vec[0]+vec[1]==vec[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
  


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

#define ll long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define F first
#define S second

void solve() {

}

int main() {
#ifndef ONLINE_JUDGE
	freopen("manish.txt", "r", stdin);
	//freopen("ps.txt", "w", stdout);
#endif
	int t;
	t = 1;
	while (t--) {
		ll n, x, t;
		string s;
		cin >> s;

		ll sum = 0;

		for (auto a : s) {
			sum += (a - '0');
		}

		if (sum % 9 == 0) {
			cout << "Yes";

		}
		else {
			cout << "No";
		}
	}
	return 0;
}

Measured memory_bytes: 3748
n, k , q = gets.split.map(&:to_i)
imos = Array.new(n+1, 0)
q.times do
  ai = gets.to_i
  ai -= 1
  imos[0] -= 1
  imos[ai] += 1
  imos[ai+1] -= 1
  imos[n] += 1
end
sum = Array.new(n, 0)
sum[0] = imos[0]
(1...n).each do |i|
  sum[i] = imos[i] + sum[i-1]
end
sum.map{|x| x + k}.each do |x|
  if x > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 4860
#include<stdio.h>
int main(){
  int n,i,j,s=0,c,d[200010],b[200010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i+1]);
  for(i=n;i;i--){
    c=0;
    for(j=i;j<=n;j+=i)c+=b[j];
    b[i]=(d[i]+c)%2;
    s+=b[i];
  }
  printf("%d\n",s);
  for(i=j=0;i<=n;i++){
    if(j)printf(" ");
    if(b[i]){
      printf("%d",i);
      j=1;
    }
  }
  if(j)printf("\n");
  return 0;
}


Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a,b,c,C[100002];

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {
	vector<LL> A;
	cin >> N>>M;

	for (int i = 0; i < N; i++) {
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < M; i++) {
		cin >> bc.second >> bc.first;
		BC.push_back(bc);
	}

	LL B = M - 1;
	LL BB = 0;

	sort(BC.begin(),BC.end());
	sort(A.begin(), A.end());


	for (int i = 0; i < N; i++) {
		while (1) {
			if (BB >= BC[B].second) {
				B--;
				BB = 0;
			}
			if (B < 0) {
				i = N;
				break;
			}
			if (A[i] < BC[B].first) {
				A[i] = BC[B].first;
				BB++;
				break;
			}
			else {
				i = N;
				break;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3188
<?php
$L=trim(fgets(STDIN));

$p0=0;$p1=0;

for($i=0;$i<$L;$i++){
  $C=explode(' ',trim(fgets(STDIN)));
  $c=strcmp($C[0],$C[1]);

  if($c<0) $p1+=3;
  elseif($c>0) $p0+=3;
  else{
    ++$p0;
    ++$p1;
  }
}

echo $p0,' ',$p1;
?>

Measured memory_bytes: 15328
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {
	
	char a, b, c, d, op1, op2, op3;
	scanf("%c%c%c%c", &a, &b, &c, &d);
	a -= '0';
	b -= '0';
	c -= '0';
	d -= '0';

	if (a + b + c + d == 7) {
		op1 = op2 = op3 = '+';
	}
	else if (a + b + c - d == 7) {
		op1 = '+';
		op2 = '+';
		op3 = '-';
	}
	else if (a + b - c + d == 7) {
		op1 = '+';
		op2 = '-';
		op3 = '+';
	}
	else if (a - b + c + d == 7) {
		op1 = '-';
		op2 = '+';
		op3 = '+';
	}
	else if (a + b - c - d == 7) {
		op1 = '+';
		op2 = '-';
		op3 = '-';
	}
	else if (a - b - c + d == 7) {
		op1 = '-';
		op2 = '-';
		op3 = '+';
	}
	else if (a - b + c - d == 7) {
		op1 = '-';
		op2 = '+';
		op3 = '-';
	}
	else if (a - b - c - d == 7) {
		op1 = '-';
		op2 = '-';
		op3 = '-';
	}
	a += '0';
	b += '0';
	c += '0';
	d += '0';
	printf("%c%c%c%c%c%c%c=7\n", a, op1, b, op2, c, op3, d);
}

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

bool is_prime(const int x) {
    if (x == 2 || x == 3) return true;
    if (x % 2 == 0 || x % 3 == 0) return false;
    if (x % 6 != 1 && x % 6 != 5) return false;
    for (int i = 5; i * i <= x; i += 6) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (is_prime(a)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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, k;
    cin >> n >> k;
    vector<int> v(2000001);

    rep(i, n) {
        int t;
        cin >> t;
        v[t]++;
    }
    sort(v.begin(), v.end());
    vector<int>::iterator it = lower_bound(v.begin(), v.end(), 1);
    v.erase(v.begin(), it);
    int ans = 0;
    int idx = 0;
    while (v.size() - idx > k) {
        ans += v[idx++];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8192
import java.util.*;


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

        String ret="No";
        if(n==b){
            if(n!=a){
                ret="Yes";
            }
        }
        if(n==a){
            if(n!=b){
                ret="Yes";
            }
        }
        if(b==a){
            if(n!=b){
                ret="Yes";
            }
        }
        System.out.println(ret);

    }
}

Measured memory_bytes: 22612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        String[] na = new String[n];
        String[] ma = new String[m];
        for (int i = 0; i < n; i++) {
            na[i] = sc.next();
        }
        for (int i = 0; i < m; i++) {
            ma[i] = sc.next();
        }
        boolean ans = false;
        for (int i = 0; i <= n - m; i++) {
            int temp = i;
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j <= m; j++) {
                if (j == 0) {
                    int idx = 0;
                    int tempIdx = 0;
                    while (idx != -1) {
                        idx = na[temp].indexOf(ma[j], tempIdx);
                        if (idx != -1) {
                            list.add(idx);
                            tempIdx = idx + 1;
                        }
                    }
                } else {
                    if (list.size() == 0) {
                        break;
                    } else {
                        temp++;
                        if (temp - i >= m) {
                            ans = true;
                            break;
                        }
                        for (int k = list.size() - 1; k >= 0; k--) {
                            int a = list.get(k);
                            if (!na[temp].substring(a, a + m).equals(ma[j])) {
                                list.remove(k);
                            }
                        }
                    }
                }
            }
            if (ans) {
                break;
            }
        }
        System.out.println(ans ? "Yes" : "No");
    }
}

Measured memory_bytes: 21076
#include<stdio.h>
int main(void)
{

	int N[50];
	
	int n;//たこ焼きの個数
	int i;//何番目のたこ焼きか
	int kazu;

	scanf("%d",&n);//たこ焼きの個数

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

	int souwa = 0;

	for(i=0;i<n-1;i++)
		for(kazu = i+1;kazu<n;kazu++)
				souwa +=N[i]*N[kazu];

	printf("%d",souwa);

	return 0;
}

Measured memory_bytes: 128
_, *d = [list(map(int, s.split())) for s in open(0)]

d = sorted(d)
dd = []
for x, l in d:
    dd.append([x-l, x+l])

max_ = dd[0][0]
n = 0
for r, l in dd:
    if max_ <= r:
        n += 1
        max_ = l
    elif max_ > l:
        max_ = l
print(n)

Measured memory_bytes: 41044
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
using namespace std;
signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a = 0, b = 0,c=0,n;
	cin >> n;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (tmp % 4 == 0)a += 1;
		if (tmp % 4 == 1 || tmp % 4 == 3)b += 1;
		if (tmp % 4 == 2)c += 1;
	}
	if (a >= b||(b==a+1&&c==0&&n%2==1))cout << "Yes";
	else cout << "No";
	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.IntSet as Set

main :: IO ()
main = do
  [n,k] <- readInts
  replicateM k (readInts >> readInts) >>= output . solve n . concat

solve :: Int -> [Int] -> _
solve n = Set.size . (xs Set.\\) . Set.fromList
  where
    xs = Set.fromList [1..n]

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    int mn = max(-1000000, x - k);
    int mx = min(1000000, x + k);
    for(int i=mn+1;i<mx;i++){
        cout << i << ' ';
    }
    cout << endl;
}

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

using namespace std;

using bellman_cost = long long;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	// from, to, cost
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex
{
	T cost;
	bool valid = false; // 到達不能または無限にコストが減るときfalse
	Vertex(T v1) : cost(v1) {}
	Vertex() {}
};
using vertex = Vertex<bellman_cost>;

template<class T>
struct Edge
{
	int to;
	T cost;
	Edge(int t, T c) : to(t), cost(c) {}
	Edge() {}
};
using edge = Edge<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class V, class E>
void Bellmanford(Graph<V, E>& G, int s, bellman_cost INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST, vv.valid = false;
	v[s].cost = 0, v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	auto valid_check = [&](auto f, int pos) {
		if (!v[pos].valid) return;
		v[pos].valid = false;
		for (auto& y: e[pos]) {
			f(f, y.to);
		}
	};
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				valid_check(valid_check, x.to);
			}
		}
	}
}

void ABC137_E() {
	int N, M, P;
	cin >> N >> M >> P;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		G.add_edge(a-1, b-1, P-c);
	}
	Bellmanford(G, 0, LLONG_MAX);
	if (G.v[N-1].valid) {
		cout << max(0LL, -G.v[N-1].cost) << endl;
	} else {
		cout << -1 << endl;
	}
}

int main() {
	ABC137_E();
}

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

using namespace std;

int main(){
    int X,Y,a;
    string ans="No";
    cin >> X >> Y ;
    if(Y%2==0){
        a=4*X-Y;
        if(a>=0){
            if(X-a/2>=0){
                ans="Yes";
            }
        }
    }
    
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3132
import heapq
Q = []
while True:
    order = input().strip().split()
    if order[0] == 'end':
        break
    elif order[0] == 'insert':
        num = -1 * int(order[1])
        heapq.heappush(Q,num)
    else:
        M = -1 * heapq.heappop(Q)
        print(M)


Measured memory_bytes: 45312
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  ll n;
  cin>>n;

  string res="";
  vi v;
  while(n>0){
    n--;
    res+=char('a' + (n%26));
    n/=26;
  }
  reverse(all(res));
  cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3636