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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
  vector<pair<ll,int>> C;
  for(int i = 0 ; i < N ; i++){
    C.push_back({A[i] + B[i], i});
  }
  sort(C.rbegin(), C.rend());
  ll ans = 0;
  for(int i = 0 ; i < N ; i++){
    ans += i % 2 == 0 ? A[C[i].second] : 0;
    ans -= i % 2 == 1 ? B[C[i].second] : 0;
  }
  cout << ans << endl;
}


int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 




int main(void){
    string s;
    ll k;
    cin>>s>>k;
    ll n = s.length();
    map<char,ll>m;
    map<ll,char>inv;
    for(char x ='a';x<='z';x++){
        int y = x-'a';
        inv[y] = x;
        m[x]=26-y;
    }
    for(ll i=0;i<n;i++){
        if(k<=0)break;
        if(s[i]=='a')continue;
        if(m[s[i]]<=k){
            k-=m[s[i]];
            s[i]='a';
        }
    }
    if(k==0){
        cout<<s<<endl;
    }
    else{
        if(k>=26)k = k%26;
        ll x = s[n-1]-'a';
        s[n-1]=inv[x+k];
        cout<<s<<endl;
    }
    return 0;
}



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

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

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    
    if(m1 != m2) cout << "1";
    else cout << "0";
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d %d" @@ fun n a b ->
  Array.init n (fun i ->
    let s = string_of_int @@ i + 1 in
    Array.init (String.length s) (fun i -> Char.code s.[i] - Char.code '0')
    |> Array.fold_left ( + ) 0
    |> (fun n -> if a <= n && n <= b then i + 1 else 0))
  |> Array.fold_left ( + ) 0
  |> Printf.printf "%d\n"

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

const int MAXN = 1e5 + 10;
vector<int> Mat[MAXN], R;
int n, m, deg[MAXN], p[MAXN];

void del(int v) {
 for (int i = 0; i < Mat[v].size(); i++) {
   deg[Mat[v][i]]--;
   if (deg[Mat[v][i]] == 0)
     	p[Mat[v][i]] = v, R.push_back(Mat[v][i]);
 }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m + n - 1; i++) {
    int a, b;
    cin >> a >> b;
    Mat[a].push_back(b);
    deg[b]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0)
    	R.push_back(i);
  while (!R.empty()) {
    int v = R.back();
    R.pop_back();
    del(v);
  }
  for (int i = 1; i <= n; i++)
    cout << p[i] << '\n';
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n,a,b,i;
  cin >> n >> a >> b;
  int ans=0;
  for(i=1;i<=n;i++){
    if(digit(i)>=a && digit(i)<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3528
<?php
$tree_num = explode(' ', trim(fgets(STDIN)));
$needed=$tree_num[1]-1;
while ($line = fgets(STDIN)) {
    $trees[] = trim($line);
}
 
$index = 0;
$final_answer = 10000000000;
rsort($trees);
 
foreach ($trees as $tree) {
    if($index+$needed+1>count($trees)){continue;};
    $answer= $tree-$trees[$needed+$index];
 
    if ($final_answer > $answer) {
        $final_answer = $answer;
    }
    $index += 1;
}
echo($final_answer);
 
?>
  


Measured memory_bytes: 22004
from collections import Counter

# s = input()
N = int(input())
A = list(map(int, input().split()))
# a, b = map(int, input().split())

c = Counter()

for a in A:
    c[a] += 1

k = list(c.keys())
v = list(c.values())
if len(v) == 1:
    if k[0]^k[0] == k[0]:
        print("Yes")
        exit()


if len(v) == 2 and N%3 == 0:
    if v[0]*2 == v[1]:
        if k[1]^k[1] == k[0]:
            print("Yes")
            exit()
    if v[1]*2 == v[0]:
        if k[0]^k[0] == k[1]:
            print("Yes")
            exit()


if len(v) == 3:
    if v[0] == v[1] and v[1] == v[2]:
        if k[0]^k[1] == k[2]:
            print("Yes")
            exit()

print("No")




Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  =  vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int x = h1 * 60 + m1;
    int y = h2 * 60 + m2;

    int dif = y - x;
    cout << max(dif - k, 0LL) << endl;

    return 0;
}


Measured memory_bytes: 3632
def insertion_sort(a, g, n):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt

def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt)

n = int(input())
a = [int(input()) for _ in range(n)]

shell_sort(a, n)
print('\n'.join(map(str, a)))



Measured memory_bytes: 125976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var hoge = IO.GetIntList();
            var ans = hoge[0] == hoge[1] ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }

    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

int main() {
  string s;
  cin >> s;
  if(s == "SUN") {
    cout << 7 << endl;
  }
  if(s == "MON") {
    cout << 6 << endl;
  }
  if(s == "TUE") {
    cout << 5 << endl;
  }
  if(s == "WED") {
    cout << 4 << endl;
  }
  if(s == "THU") {
    cout << 3 << endl;
  }
  if(s == "FRI") {
    cout << 2 << endl;
  }
  if(s == "SAT") {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

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

using namespace std;

int cnt;
vector<pair<int,int> > card;

int main()
{
	int n;
	int dp[8][1001];
	while(cin >> n && n)
	{
		card.clear();
		int a,b;

		rep(i,n)
		{
			cin >> a >> b;
			card.push_back(make_pair(a,b));
		}
		
		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;
		
		rep(i,n)
		{
			rep(j,1001)
			{
				rep(k,card[i].second+1)
				{
					if(j + card[i].first*k <= 1000) dp[i+1][j+card[i].first*k] += dp[i][j];
				}
			}
		}

		int g;
		cin >> g;

		rep(i,g)
		{
			int n2;
			cin >> n2;
			
			cout << dp[n][n2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""


import math


def getInt(): return int(input())


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


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def dmp(x):
    global debug
    if debug:
        print(x)


# ABC 100 B Ringo's Favorite Numbers
def abc100b():
    D, N = getIntList()
    if N % 100 == 0:
        return (N+1) * 100**D  # WA N==100のとき正しくない 101*100**D
    else:
        return N * 100**D


# ABC 101 B digit sum
def abc101b():
    N = getInt()
    sm = 0
    n = N
    while n > 0:
        sm += n % 10
        n //= 10
    if N % sm == 0:
        return 'Yes'
    else:
        return 'No'


# ABC 102 B Maximum Difference
def abc102b():
    N = getInt()
    A = getIntList()
    return max(A) - min(A)


debug = False  # True False
print(abc102b())


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    string s, t, u;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;
    cin >> u;

    if (s == u)
        cout << a - 1 << " " << b << endl;

    if (t == u)
        cout << a << " " << b - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
use whiteread::parse_line;

fn main() {
    let x: i64 = parse_line().unwrap();
    let mut num: i64 = 100;
    let mut count: usize = 1;
    loop {
        num = (num / 100) + num;
        if num >= x {
            break;
        }
        count = count + 1;
    }
    println!("{}", count);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 探索用の組み合わせ表現
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    vector<vector<char>> S(H+1, vector<char>(W+1));

    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            cin >> S[i][j];
        }
    }

    vector<vector<ll>> dp(H+1, vector<ll>(W+1, INF));

    if(S[1][1] == '#') dp[1][1] = 1;
    if(S[1][1] == '.') dp[1][1] = 0;

    REP(i, H+1){
        dp[i][0] = 0;
    }
    REP(i, W+1){
        dp[0][i] = 0;
    }

    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            for(ll dir = 0; dir < 2; dir++) {
                ll ni = i + dx[dir], nj = j + dy[dir];
                if (ni > H || nj > W) continue;
                ll add = 0;
                if (S[ni][nj] == '#' && S[i][j] == '.') add = 1;
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add);
            }
        }
    }

    cout << dp[H][W] << endl;
    return 0;
}

Measured memory_bytes: 384
s = list(input())

places_R = []

for i in range(len(s) - 1):
    if(s[i] == 'R' and s[i+1] == 'L'):
        places_R.append(i)

places_L = places_R[:]
for i in range(len(places_L)):
    places_L[i] += 1

# print(places_R)
# print(places_L)

result = [0] * len(s)

for i in places_R:
    from_left = 0 # 左側から到達する人数
    from_right = 0 # 右側から到達する人数

    j = 1
    while(i-j-1 >= 0 and s[i-j] == 'R' and s[i-j-1] == 'R'):
        from_left += 1
        j += 2

    j = 1
    while(i+j+1 <= len(s)-1 and s[i+j] == 'L' and s[i+j+1] == 'L'):
        from_right += 1
        j += 2

    # 左側から + 右側から + もとからその位置
    result[i] = from_left + from_right + 1

for i in places_L:
    from_left = 0 # 左側から到達する人数
    from_right = 0 # 右側から到達する人数

    j = 1
    while(i-j-1 >= 0 and s[i-j] == 'R' and s[i-j-1] == 'R'):
        from_left += 1
        j += 2

    j = 1
    while(i+j+1 <= len(s)-1 and s[i+j] == 'L' and s[i+j+1] == 'L'):
        from_right += 1
        j += 2

    # 左側から + 右側から + もとからその位置
    result[i] = from_left + from_right + 1

print(' '.join([str(i) for i in result]))

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




int A, B, C;
int ans = 0;
//-----------------------------------------------------------------
bool chk() {
    if (A == 0) return false;
    if (B == 0) return false;
    if (C == 0) return false;

    if (A % 2) return false;
    if (B % 2) return false;
    if (C % 2) return false;

    return true;
}
//-----------------------------------------------------------------
int main() {
    cin >> A >> B >> C;
    
    while (chk()) {
        int a = B / 2 + C / 2;
        int b = A / 2 + C / 2;
        int c = A / 2 + B / 2;

        A = a, B = b, C = c;
        ans++;
        if (101010 < ans) {
            ans = -1;
            break;
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 256
from sys import stdin
S = (stdin.readline().rstrip())
T = (stdin.readline().rstrip())

def count_match(a,b):
    cnt = 0
    for w1,w2 in zip(a,b):
        if w1 == w2:
            cnt += 1
    return cnt

flag = False
for i in range(len(S)-len(T)+1):
    match = count_match(S[i:i+len(T)],T) + S[i:i+len(T)].count("?")
    if match == len(T):
      flag = True
      ans = S[:i] + T + S[i+len(T):]
      ans = ans.replace("?","a")
if flag:
  print(ans)
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int ans = 0;
	sort(arr, arr + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				int a = arr[i], b = arr[j], c = arr[k];

				if (a + b > c && (a != b && b != c && c != a))
				{
					ans++;
				}
			}
		}

	}
	cout << ans;



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3672
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  ve<int> A(3);
  rep(i, 3){
    ci(A.at(i));
  }
  sort all(A);
  co(A.at(2) - A.at(0));
}

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

int main() {
    while (1) {
        int n, m;
        cin >> n >> m;
        if (!(n)) break;
        
        vector<int> v(n);
        for (int i = 0; i < n; i++) {
            cin >> v.at(i);
        }
        
        int sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                int x = v.at(i) + v.at(j);
                if ((x <= m) && (sum < x)) {
                    sum = x;
                }
            }
        }
        
        if (!(sum)) {
            cout << "NONE" << endl;
        } else {
            cout << sum << endl;
        }
    }
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int N=1000001;
const int INF = 1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n)
        cin>>a[i];
    LL ans=0;
    REP(i,n)
    {
        if(i>0)
        {
            int t=min(a[i],a[i-1]);
            ans+=t;
            a[i]-=t;
            a[i-1]-=t;
        }

        ans+=a[i]/2;
        a[i]%=2;


        if(i<n-1)
        {
            int t=min(a[i],a[i+1]);
            ans+=t;
            a[i]-=t;
            a[i+1]-=t;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if ((N+M)%2 == 0) {
			System.out.println((N+M)/2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 21844
nv, ne = map(int, input().split(' '))
edges = []
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    edges.append((s, t, w))

dist = [[float('inf')] * nv for i in range(nv)]
for i in range(nv):
    dist[i][i] = 0
for s, t, w in edges:
    dist[s][t] = w

for k in range(nv):
    for i in range(nv):
        for j in range(nv):
            if dist[i][j] > dist[i][k] + dist[k][j]:
                dist[i][j] = dist[i][k] + dist[k][j]

for i in range(nv):
    if dist[i][i] < 0:
        print("NEGATIVE CYCLE")
        exit()

for row in dist:
    print(' '.join(str(d) if d < float('inf') else 'INF' for d in row))

Measured memory_bytes: 8972
package main

import (
	"fmt"
)

func main() {
	var n, T int
	fmt.Scan(&n,&T)

	c := make([]int,n)
	t := make([]int,n)
	for i:=0;i < n; i++ {
		fmt.Scan(&c[i],&t[i])
	}

	min := 1001
	for i:=0;i < n; i++{
		if t[i] > T {
			continue
		}
		
		if c[i] < min {
			min = c[i]
		}
	}

	if min == 1001 {
		fmt.Println("TLE")
	}else{
		fmt.Println(min)
	}
}




Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
	int ue,shita,kita,nishi,higashi,minami,a,c,i;
	char d[6],b;
	while(1){
	ue=1;
	shita=6;
	kita=5;
	nishi=4;
	minami=2;
	higashi=3;
		c=1;
		scanf("%d",&a);
		if(a==0){
			return 0;
		}
		for(i=0;i<a;i++){
			scanf("%s",&d);
			if(strcmp(d,"North") == 0){
				b=ue;
				ue=minami;
				minami=shita;
				shita=kita;
				kita=b;
			}else if(strcmp(d,"East") == 0){
				b=ue;
				ue=nishi;
				nishi=shita;
				shita=higashi;
				higashi=b;
			}else if(strcmp(d,"West") == 0){
				b=ue;
				ue=higashi;
				higashi=shita;
				shita=nishi;
				nishi=b;
			}else if(strcmp(d,"South") == 0){
				b=ue;
				ue=kita;
				kita=shita;
				shita=minami;
				minami=b;
			}else if(strcmp(d,"Right") == 0){
				b=nishi;
				nishi=minami;
				minami=higashi;
				higashi=kita;
				kita=b;
			}else if(strcmp(d,"Left") == 0){
				b=nishi;
				nishi=kita;
				kita=higashi;
				higashi=minami;
				minami=b;
			}
		c+=ue;
		}
		printf("%d\n",c);
	}
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n, k;
    cin >> n >> k;

    mint ans = 0;
    for(ll ki = k; ki <= n + 1; ++ki){
        const ll minval = (ki - 1) * ki / 2;
        const ll maxval = (n + n - ki + 1) * ki / 2;
        ans += (maxval - minval + 1);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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;}

void solve() {
    string s;
    cin >> s;
    for (int i = 0; i + 1 < s.size(); i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return;
        }
    }
    for (int i = 0; i + 2 < s.size(); i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))

m = 0
t = 0

pre = H[0]
for hi in H[1:]:
    if pre >= hi:
        t += 1
    else:
        m = max(m, t)
        t = 0
    pre = hi

print(max(m, t))

Measured memory_bytes: 14224
#!python3

LI = lambda: list(map(int, input().split()))

# input
H, W, K = LI()
C = [input() for _ in range(H)]


def solve(n1, n2):
    l1 = {i for i in range(H) if (n1 >> i) % 2 == 1}
    l2 = {i for i in range(W) if (n2 >> i) % 2 == 1}
    k = 0
    for i in range(H):
        if i in l1:
            continue
        for j in range(W):
            if j in l2:
                continue
            if C[i][j] == "#":
                k += 1
    if k == K:
        return 1
    else:
        return 0


def main():
    n1, n2 = 2 ** H, 2 ** W
    ans = 0
    for i in range(n1):
        for j in range(n2):
            ans += solve(i, j)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
import java.util.Scanner;
class Main{
  public static void main(String args[]){
	Scanner scanner=new Scanner(System.in).useDelimiter("\\s");
	int maxAmountofA=scanner.nextInt();
    int currentAmountofA=scanner.nextInt();
    int currentAmountofB=scanner.nextInt();
    if(maxAmountofA-currentAmountofA>=currentAmountofB){
    	System.out.println(0); 
    }else{
    	currentAmountofB-=(maxAmountofA-currentAmountofA);
      	System.out.println(currentAmountofB);
    }
	//int maxAmountOfA=
  }
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>

#define false -1
#define true 1

int isPrime(int);

int main()
{
  int i, n, put[10000], hantei, count = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&put[i]);
      hantei = isPrime(put[i]);
      if(hantei == true)count++;
    }

  printf("%d\n",count);
  
  return 0;
}

int isPrime(int x)
{
  int i;
  
  if(x == 2)return true;

  if(x < 2 || x%2 == 0)return false;

  i = 3;
  while(i <= sqrt(x))
    {
      if(x%i == 0)return false;
      i += 2;
    }
  
  return true;
}



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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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


auto solve() {
    int n, k;
    cin >> n >> k;
    return !(n < k * 2 - 1);

}


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

//    cout << (solve() ? "even" : "odd") << endl;
    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 892
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;


int main() {
	long long  n;
	cin >> n;
	long long ans = 0;
	for (long long i = 1; i < sqrt(n); i++) {
		if (n % i != 0) continue;
		if (abs(n / i - i) < 2) continue;
		ans += n / i - 1;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 256
// ABC139 C - Lower
//20190902

using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            //入力受け取り
            int N = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string[] arr = str.Split(' ');

            double[] H = new double[N];

            //後でforeach文で書く練習をする。
            for (int i = 0; i < N; i++)
            {
                H[i] = double.Parse(arr[i]);
            }

            //計算
            int Start = 0;
            int p = 0;
            int MAXPivot = 0;

            while (p + 1 < N)
            {
                Start = p;

                while (p<N-1 && H[p] >= H[p + 1])
                {
                    p += 1;
                }

                if (MAXPivot < p - Start)
                {
                    MAXPivot = p - Start;
                }

                p += 1;
            }


            //出力
            Console.WriteLine(MAXPivot);
        }
    }
}


Measured memory_bytes: 23388
#include<stdio.h>
#define N 10000

 main(){
  int i,j,k,l,count=0,a[N],b,c[N],d;
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&d);
  for(j=0;j<d;j++){
    scanf("%d",&c[j]);
  }

 for(i=0;i<d;i++){
    for(j=0;j<b;j++){
      if(a[j]==c[i]){   
	count++;
	break;
      }
    }
  }
 printf("%d\n",count);
 return 0;
 }

Measured memory_bytes: 644
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        s:Chars,
        mut k:usize,
    }

    let len = s.len();
    let mut ss = s.clone();
    ss.append(&mut s.clone());
    ss.append(&mut s.clone());

    let mut ct0 = 0;
    let mut ct1 = 0;
    let mut ct2 = 0;
    for i in 1..len * 3 {
        if ss[i] == ss[i - 1] {
            ss[i] = 'X';
            if i < len {
                ct0 += 1;
            } else if i < len * 2 {
                ct1 += 1;
            } else {
                ct2 += 1;
            }
        }
    }

    // ct0 + ct1 + ct2 + ct1 + ct2 + ct1 + ct2 .... の形になる
    let mut ct = 0;
    ct += ct0;
    k -= 1;
    ct += (k / 2) * (ct1 + ct2) + (k % 2) * ct1;

    println!("{}", ct);
}


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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e5;
struct Edge
{
	int v,nxt;
} e[(N<<1)+3];
int fe[N+3];
int du[N+3];
int n,m,en;

void addedge(int u,int v)
{
	du[u]++;
	en++; e[en].v = v;
	e[en].nxt = fe[u]; fe[u] = en;
}

int dfs(int u,int prv,int s)
{
	if(du[u]==4) {return u==s;}
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v; if(v==prv) continue;
		return dfs(v,u,s);
	}
}

int main()
{
	scanf("%d%d",&n,&m); en = 1;
	for(int i=1; i<=m; i++)
	{
		int u,v; scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	int cnt6 = 0,cnt4 = 0,cntodd = 0;
	for(int i=1; i<=n; i++) {if(du[i]&1) cntodd++; if(du[i]>=6) cnt6++; else if(du[i]==4) cnt4++;}
	if(cntodd) {puts("No"); return 0;}
	else if(cnt6) {puts("Yes"); return 0;}
	else if(cnt4>=3) {puts("Yes"); return 0;}
	else if(cnt4<=1) {puts("No"); return 0;}
	int u = 0,v = 0;
	for(int i=1; i<=n; i++) if(du[i]==4) {u?v=i:u=i;}
	int ans = 0;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		ans |= dfs(e[i].v,u,u);
	}
	if(ans) puts("Yes"); else puts("No");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
    if(N % 2 == 0){
  cout << N / 2 << endl;
    }
  else{
cout << N / 2 + 1 << endl;
  }

  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compare(const void* a, const void* b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    scanf("%d", &n);
    int x[n][2];
    for(int i=0; i<n; i++){
        scanf("%d", &x[i][0]);
        x[i][1] = i;
    }

    qsort(x, n, sizeof(int)*2, compare);

    int ans[n];
    for(int i=0; i<(n/2); i++){
        ans[x[i][1]] = x[n/2][0];
    }
    for(int i=n/2; i<n; i++){
        ans[x[i][1]] = x[(n/2)-1][0];
    }

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

    return 0;

}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M, vector<int>());
    vector<int> p(M);
    for(int i = 0; i < M; i++){
        int k;
        cin >> k;//k <= N
        s[i].resize(k);
        for(int j = 0; j < k; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i = 0; i < M; i++)cin >> p[i];
    
    int ans = 0;
    for(int tmp = 0; tmp < (1 << N); tmp++){
        int lamp = 0;
        for(int i = 0; i < M; i++){
            int cnt = 0;
            for(int j = 0; j < s[i].size(); j++){
                if(tmp & (1 << s[i][j]))cnt++;
            }
            if(cnt % 2 == p[i])lamp++;
        }
        if(lamp == M)ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=input()
A=input().split()
N=int(N)
for i in range(N):
    A[i]=int(A[i])

counter=0 #答え（初期化）


while True:
    flag_cando=1 #操作可能フラグ
    for i in range(N):
        if A[i]%2!=0: #奇数
            flag_cando=0
            break
    if flag_cando==0:
        break
    else: #奇数のものが無かったら
        #全ての数値を2で割る
        for i in range(N):
            A[i]=int(A[i]/2)
        #操作カウントを増やす
        counter+=1

print(counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define p32 pair <int,int>
#define p64 pair <ll,ll>
#define mp make_pair
using namespace std;

const int M=1e9+7;
const int NM=2e5;

ll p[105],w[105],dp[NM];

int main()
{   /// dp[i]=minimum weight to get objects in value of i
    int n,g;
    cin>>n>>g;
    ll s=0;
    for(int i=1; i<=n; i++)
    {   cin>>w[i]>>p[i];
        s+=p[i];
    }
    fill(dp+1,dp+s+1,1e18);
    for(int i=1; i<=n; i++)
        for(int j=s; j>=p[i]; j--)
            if(j-p[i]==0 || dp[j-p[i]]!=1e18)
                dp[j]=min(dp[j],dp[j-p[i]]+w[i]);
    ll sol=0;
    for(int i=1; i<=s; i++)
        if(dp[i]<=g)
            sol=i;
    cout<<sol;
    return 0;
}

Measured memory_bytes: 4324
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

const int d4[4][2] = {
    {1, 0},
    {0, 1},
    {-1, 0},
    {0, -1},
};

bool solve() {
    bool g[8][8];
    for (int i = 0; i < 8; i++) {
        string s; cin >> s;
        for (int j = 0; j < 8; j++) {
            g[i][j] = (s[j] == '1');
        }
    }

    int x, y;
    cin >> x >> y; x--; y--;

    using P = pair<int, int>;
    queue<P> q;
    q.push(P(x, y));
    bool bk[8][8] = {};
    while (q.size()) {
        int x, y;
        tie(x, y) = q.front(); q.pop();
        if (bk[y][x] or !g[y][x]) continue;
        bk[y][x] = true;
        for (int d = 0; d < 4; d++) {
            int nx = x, ny = y;
            for (int i = 0; i < 3; i++) {
                nx += d4[d][0]; ny += d4[d][1];
                if (!(0 <= nx and nx < 8 and 0 <= ny and ny < 8)) continue;
                q.push(P(nx, ny));
            }
        }
    }
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (!g[i][j] or bk[i][j]) {
                cout << '0';
            } else {
                cout << '1';
            }
        }
        cout << endl;
    }
    return true;
}

int main() {
    int ca = 0;
    cin >> ca;
    for (int i = 0; i < ca; i++) {
        cout << "Data " << i+1 << ":" << endl;
        if (!solve()) break;
    }
    return 0;
}

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

int main(){
    int n,l; cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    string ans = "";
    rep(i,n) ans += s[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x, n = gets.to_s.split.map{|t|t.to_i}
q    = gets.to_s.split.map{|t|t.to_i}.sort

0.upto(100) do |i|
  
  if !q.include?(x-i)
    puts x - i
    exit
  elsif !q.include?(x+i)
    puts x + i
    exit
  end
end

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

char a[10][10];

int main(){
  int h, w;
  cin >> h >> w;
  for(int i = 1 ; i <= h ; i++){
    for(int j = 1 ; j <= w ; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 1 ; i <= h ; i++){
    for(int j = 1 ; j <= w ; j++){
      for(int x = 1 ; x < i ; x++){
        for(int y = j+1 ; y <= w ; y++){
          if(a[i][j]=='#'&&a[x][y]=='#'){
            cout << "Impossible";
            return 0;
          }
        }
      }
    }
  }
  cout << "Possible";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> to;
int memo[100000];
int dfs(int now) {
  if (memo[now] >= 0)
    return memo[now];
  if (!to[now].size())
    return memo[now] = 0;
  for (auto next : to[now])
    chmax(memo[now], dfs(next)+1);
  return memo[now];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  to.resize(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    to[x].push_back(y);
  }
  memset(memo, -1, sizeof(memo));
  int ans = 0;
  rep(i, n) chmax(ans, dfs(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7552
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  cout<<s[0]<<n-2<<s[n-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100010
const long long M = 1000000007;
using namespace std;
long long dp[MAXN];
long long N, K;

int pot(long long a, long long b){
    long long ans = 1;
    while(b){
        if(b&1){
            ans = (ans * a) % M;
        }
        a = (a * a) % M;
        b >>= 1;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    N = 3;
    cin >> K;
    long long ans = 0;
    for(int i = K; i > 0; i--){
        dp[i] = pot(K / i, N);
        for(int j = i+i; j <= K; j += i){
            dp[i] -= dp[j];
        }
        dp[i] = ((dp[i] % M) + M) % M;
        ans += i * dp[i];
        ans %= M;
    }
    
    ans = ((ans % M) + M) % M;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3652
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	
	int f = 0;
	foreach(c; s){
		if(f == 0 && c == 'C') f = 1;
		if(f == 1 && c == 'F') f = 2;
		}
	
	string ans;
	if(f == 2) ans = "Yes";
	else ans = "No";
	
	ans.writeln;
	
	}

Measured memory_bytes: 380
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 3005;
const int mod = 998244353;


int f[maxn][maxn];
int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i];
  f[0][0] = 1;
  for(int i=1;i<=n;i++)f[i][0] = f[i-1][0] * 2 %mod;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
      f[i][j] = f[i-1][j] * 2 % mod;
      if(j>=a[i])f[i][j] = (f[i][j]+f[i-1][j-a[i]])%mod;
    }
  cout<<f[n][m]<<endl;
  return 0;
}

Measured memory_bytes: 38824
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int a, b, c;
	string ans = "bust";
	cin >> a >> b >> c;
	if (a + b + c < 22) {
		ans = "win";
	}
	cout << ans;
	
}

Measured memory_bytes: 504
S = input()
ans = 0

for i in range(len(S)):
  num = 0
  for j in range(i,len(S)):
    if S[j]=='A' or S[j]=='G' or S[j]=='C' or S[j]=='T':
      num += 1
    else:
      break
  ans = max(num, ans)
  
print(ans)

Measured memory_bytes: 2940
#include<stdio.h>
#define N 100

void matrixChainOrder(int);

int p[N];
int m[N][N];
int n;


int main(){
  int n,c;
  int i;

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

  matrixChainOrder(n);

  printf("%d\n",m[1][n]);
  return 0;

}



void matrixChainOrder(int n){
  int i,l,k;
  int q,j;

  
  for( i=1 ; i<=n ; i++ )
    m[i][i] = 0;

  for( l=2 ; l<=n ; l++ ){
    for( i=1 ; i<=n-l+1 ; i++ ){
      j = i+l-1;
      m[i][j] = 100000000;
      for( k=i ; k<j ; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if( m[i][j] > q)m[i][j] = q;
      }
    }
  }
}

Measured memory_bytes: 636
from math import ceil
n = int(input())
A = list(map(int,input().split()))[::-1]
mn,mx = A[0], A[0]
step = [[mn,mx]]
for i in range(1, n+1):
    mn = ceil(mn/2) + A[i]
    mx = mx + A[i]
    step.append([mn,mx])
if not mn<=1 and 1<=mx:
    print(-1)
else:
    step = step[::-1]
    A = A[::-1]
    now = 1
    ans = 1
    for i in range(1, n+1):
        now = min(step[i][1],
                  (now-A[i-1])*2)
        ans += now
    print(ans)

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

int main() {
	string s;
	cin >> s;
	bool elf = false;
	if (s[2] == s[3] && s[4] == s[5]) elf = true;
	puts(elf ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int a, b, c; ll k;
	cin >> a >> b >> c >> k;
	if (k % 2) cout << b - a << endl;
	else cout << -(b - a) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline
 
def main():
    n, k = map(int, input().split())
    x = sorted([list(map(int, input().split())) for _ in range(n)])
    cnt = 0
    for a, b in x:
        cnt += b
        if cnt >= k:
            print(a)
            exit()
    
main()


Measured memory_bytes: 57180
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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;}

#define P (1'000'000'007)

signed main() {
    int d, g;
    cin >> d >> g;

    vi vs;
    vp vc;

    rep(i, d) {
        int p, c;
        cin >> p >> c;

        vs.push_back(p - 1);
        vc.push_back(make_pair(p, (i + 1) * 100 * p + c));
    }
    
    int ans = INT_MAX;
    rep(i, 1 << d) {
        int cost = g;
        int res = 0;
        rep(j, d) {
            if (((1 << j) & i) > 0) {
                cost -= vc[j].second;
                res += vc[j].first;
            }
        }

        for (int j = d - 1; j >= 0; --j) {
            if (cost <= 0) break;
            if(((1 << j) & i) > 0) continue;
            int x = min(vs[j], 1 + (cost - 1) / ((j + 1) * 100));
            res += x;
            cost -= x * (j + 1) * 100;
        }

        if (cost <= 0) {
            chmin(ans, res);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3156
/* B */

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int left = 0, right = 0;

	for (int i = 0; i < m; ++i)
	{
		int tmp;
		cin >> tmp;
		if(tmp < x){
			left += 1;
		}else{
			right += 1;
		}
	}

	cout << min(left, right) << endl;

	return 0;

}

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

Measured memory_bytes: 32152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 vector<int> vec{0,1,3,1,2,1,2,1,1,2,1,2,1};
 int a,b;
 cin>>a>>b;
 
 if(vec.at(a)==vec.at(b))
 	cout<<"Yes"<<endl;
 else
 	cout<<"No"<<endl;
 
 
 return 0;
 }

Measured memory_bytes: 256