akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFiftyFifty solver = new AFiftyFifty();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFiftyFifty {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int[] a = new int[26];
            String str = s.next();
            for (int i = 0; i < str.length(); i++)
                a[str.charAt(i) - 'A']++;
            int count = 0;
            for (int i = 0; i < 26; i++)
                if (a[i] == 2)
                    count++;
            if (count == 2)
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int f=0;
    int k,a,b; cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            f=1;
            break;
        }
    }
    if(f) cout<<"OK\n";
    else cout<<"NG\n";
    return 0;
}

Measured memory_bytes: 3636
n = int(input())

a_arr = list(map(int, input().split()))
b_arr = list(map(int, input().split()))

a_left = a_arr[0]
b = b_arr[0]

counter = 0

for i in range(n):
    a_right = a_arr[i + 1]
    b = b_arr[i]
    killed = b if a_left > b else a_left
    b -= killed
    counter += killed
    killed = b if a_right > b else a_right
    a_left = a_right - killed
    counter += killed

print(int(counter))

Measured memory_bytes: 82020
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int maxn = 100005;


int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
   string s;
   cin>>s;
   int n = s.size();
   cout<<s.substr(0,n-8)<<endl;
   return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut a = vec![0u64; n];
    let mut b = vec![0u64; n];
    let mut c = vec![0u64; n];
    for i in 0..n {
        let v = read_vec::<u64>();
        a[i] = v[0];
        b[i] = v[1];
        c[i] = v[2];
    }
    let mut dp_a = vec![0u64; n];
    let mut dp_b = vec![0u64; n];
    let mut dp_c = vec![0u64; n];

    dp_a[0] = a[0];
    dp_b[0] = b[0];
    dp_c[0] = c[0];

    for i in 1..n {
        dp_a[i] = std::cmp::max(dp_b[i - 1], dp_c[i - 1]) + a[i];
        dp_b[i] = std::cmp::max(dp_a[i - 1], dp_c[i - 1]) + b[i];
        dp_c[i] = std::cmp::max(dp_a[i - 1], dp_b[i - 1]) + c[i];
    }
    let ans = std::cmp::max(std::cmp::max(dp_a[n - 1], dp_b[n - 1]), dp_c[n - 1]);
    println!("{:?}", ans);
}


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

string d[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(){
  string s;
  cin>>s;
  for(int i=0;i<7;++i){
    if(d[6-i]==s){
      cout<<i+1;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N;
	cin >> N;
	int ans = 0;
	rep(i, N) {
		int a;
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str = br.readLine();
	    StringTokenizer st = new StringTokenizer(str, " ");

		int w  = Integer.parseInt(st.nextToken());
		int h  = Integer.parseInt(st.nextToken());
		int x  = Integer.parseInt(st.nextToken());
		int y  = Integer.parseInt(st.nextToken());
		int r  = Integer.parseInt(st.nextToken());

		if(w >= (x + r) && h >= (y + r ) && x >= r && y >= r ) {
			System.out.println("Yes");

		}else {
			System.out.println("No");
		}

	}

}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,0,n){
        cin>>h[i];
    }
    
    int ans=h[0];
    rep(i,0,n-1){
        int tmp=h[i];
        if(tmp<h[i+1]){
            ans+=h[i+1]-tmp;
        }
    }

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

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

int main(){
  int a,b,c,e;
  cin>>a>>b;
  c=0;
  e=0;
  vector<int> d(a);
  for(int i=0;i<a;i++){
    cin>>d.at(i);
    }
  for(int i=0;i<a;i++){
    c+=d.at(i);
    }
  if(b>=c)
    cout<<a+1<<endl;
  else{
    c=0;
  for(int i=0;i<a;i++){
    c+=d.at(i);
    if(c>b){
      cout<<e+1<<endl;
      break;
      }
    e++;
    }
    }
  }
  

Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    int r,g;
    scanf("%d%d",&r,&g);
    printf("%d\n",2*g-r);
    return 0;
}

Measured memory_bytes: 128
R,G,B,N = map(int,input().split())

li = [R,G,B]
li.sort(reverse=True)
R = li[0]
G = li[1]
B = li[2]
#print(R,G,B)

ans = 0
for b in range(N//B+1):
    for g in range((N-B*b)//G+1):
        if N-B*b-G*g >= 0 and (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)


Measured memory_bytes: 40940
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

typedef vector<double> vec;
typedef vector<vec> vec2;
typedef vector<vec2> vec3;
typedef vector<vec3> vec4;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

enum { LT, RT, LK, RK, NONE };

int main() {
	for(;;) {
		int acc[4][4];
		for(int i = 0; i < 4; ++i)
			scanf("%d", &acc[0][i]);

		if(acc[0][0] < 0)
			break;

		for(int i = 1; i < 4; ++i)
			for(int j = 0; j < 4; ++j)
				scanf("%d", &acc[i][j]);

		int l;
		scanf("%d", &l);

		vector<int> s(l);
		for(int i = 0; i < l; ++i)
			scanf("%d", &s[i]);

		int a, b;
		scanf("%d %d", &a, &b);
		a /= 100;
		b /= 100;

		vec4 dp(101, vec3(5, vec2(11, vec(11, 0.0))));
		for(int i = 0; i < 5; ++i)
			for(int j = 0; j < 11; ++j)
				for(int k = 0; k < 11; ++k)
					dp[100][i][j][k] = 1.0;

		for(int next = l - 1; next >= 0; --next) {
			vec4 tmp(101, vec3(5, vec2(11, vec(11, 1.0))));
			if(s[next] == 0) {
				for(int sco = 0; sco < 100; ++sco)
					for(int pre = 0; pre < 5; ++pre)
						for(int com = 0; com <= 10; ++com)
							for(int pac = 0; pac <= 10; ++pac)
								tmp[sco][pre][com][pac] = dp[sco][NONE][com][10];
				dp.swap(tmp);
				continue;
			}

			const int start = (s[next] == 1 ? 0 : 2);
			for(int sco = 0; sco < 100; ++sco) {
				for(int pre = 0; pre < 4; ++pre) {
					for(int pac = 0; pac <= 10; ++pac) {
						for(int com = 0; com <= 10; ++com)
							tmp[sco][pre][com][pac] = dp[sco][NONE][0][10];

						for(int i = start; i < start + 2; ++i) {
							const int ac = max(0, (acc[pre][i] - 10) + pac);
							const double p = ac / 10.0;
							for(int com = 0; com <= 10; ++com) {
								const double buf = p * dp[min(100, sco + a + b * min(10, com))][i][min(10, com + 1)][ac] + (1.0 - p) * dp[sco][i][0][ac];
								chmax(tmp[sco][pre][com][pac], buf);
							}
						}
					}
				}

				for(int com = 0; com <= 10; ++com) {
					for(int pac = 0; pac <= 10; ++pac) {
						tmp[sco][NONE][com][pac] = dp[sco][NONE][0][10];
						for(int i = start; i < start + 2; ++i) {
							chmax(tmp[sco][NONE][com][pac], dp[min(100, sco + a + b * min(10, com))][i][min(10, com + 1)][10]);
						}
					}
				}
			}

			dp.swap(tmp);
		}

		printf("%.5lf\n", dp[0][NONE][0][10]);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2456
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [r] <- readInts
  print . showAnswer $ solve r

type Input  = (Int)
type Output = String

solve :: Input -> Output
solve r
  | r < 1200  = "ABC"
  | r < 2800  = "ARC"
  | otherwise = "AGC"

showAnswer :: Output -> Answer
showAnswer = String

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

-- readStrings :: IO [String]
-- readStrings = map C8.unpack . C8.words <$> C8.getLine

-- readPair :: IO (Int, Int)
-- readPair = head . unfoldr readT <$> C8.getLine
--   where
--     readT = runStateT $
--       (,) <$> StateT (C8.readInt . C8.dropWhile isSpace)
--           <*> StateT (C8.readInt . B.unsafeTail)

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

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

int main(){
    string s,t;
    cin >> s >> t;
    for(int i = s.size()-1;i >= 0;i--){
        string p = s.substr(i,t.size());
        if(p.size() != t.size()) continue;
        bool ok = true;
        for(int j = 0;j < p.size();j++){
            if(p[j] == '?') continue;
            if(p[j] != t[j]) ok = false;
        }
        if(ok){
            int cnt = 0;
            for(int j = i;j < i+t.size();j++){
                s[j] = t[cnt];
                cnt++;
            }
            replace(s.begin(),s.end(),'?','a');
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

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

int check(int a,int b,int x){
    return a*x/b-a*(x/b);
}

main (void){
    int a,b,n;
    cin>>a>>b>>n;
    if(n>=b-1){
        int ans=check(a,b,b-1);
        cout<<ans<<endl;
    }else{
        int ans=check(a,b,n);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long A[n];
    vector<long long> B(n, 1e+10);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    B[0] = A[0];
    for (int i = 1; i < n; i++)
    {
        int ind = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        B[ind] = A[i];
    }
    cout << lower_bound(B.begin(), B.end(), 1e+10) - B.begin() << endl;
}


Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int A, B, C;
    cin >> A >> B >> C;

    int result = B / A;
    result = min(result, C);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	count := bubbleSort(elems)
	fmt.Println(stringifyInts(elems))
	fmt.Println(count)
}

func bubbleSort(elems []int) int {
	count := 0
	for i := 0; i < len(elems); i++ {
		for j := 0; j < len(elems)-1-i; j++ {
			if elems[j] > elems[j+1] {
				elems[j], elems[j+1] = elems[j+1], elems[j]
				count++
			}
		}
	}
	return count
}

func stringifyInts(elems []int) string {
	xs := make([]string, len(elems))
	for i, _ := range xs {
		xs[i] = strconv.Itoa(elems[i])
	}
	return strings.Join(xs, " ")
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(num int, sc *bufio.Scanner) ([]int, error) {
	res := make([]int, num)
	for i, _ := range res {
		r, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		res[i] = r
	}
	return res, nil
}



Measured memory_bytes: 1108
#include <stdio.h>
 
int main(void)
{
  	int a;
  	int b;
  	int c;
  
  	scanf("%d %d %d", &a, &b, &c);
  	
  	if (c - (a - b) >= 0)
	  	printf("%d", c - (a - b));
  	else
      	printf("0");
    return (0); 
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  static final long INF = Long.MAX_VALUE / 2;
  static int n, m;
  static int[] a, b;
  static long[] c;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    m = sc.nextInt();
    a = new int[m];
    b = new int[m];
    c = new long[m];
    for(int i = 0; i < m; i++){
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      c[i] = sc.nextInt();
    }

    long[] dist = new long[n];
    Arrays.fill(dist, INF);

    dist[0] = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        if(dist[a[j]] != INF && dist[b[j]] > dist[a[j]] - c[j]){
          dist[b[j]] = dist[a[j]] - c[j];
        }
      }
    }

    boolean[] cycle = new boolean[n];
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        if(dist[a[j]] != INF && dist[a[j]] - c[j] < dist[b[j]]){
          cycle[b[j]] = true;
        }
        if(cycle[a[j]]){
          cycle[b[j]] = true;
        }
      }
    }

    if(cycle[n - 1]){
      System.out.println("inf");
    }
    else{
      System.out.println(-dist[n - 1]);
    }
  }
}


Measured memory_bytes: 28308
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<30;

ll N,K;
vector<ll> A;

bool C(ll c){
    vector<ll> r(N+1);
    rep(i,N) r[i] = A[i] % c;
    sort(r.begin(),r.end());
    ll rsum = 0;
    rep(i,N) rsum += r[i];
    ll l = N - (rsum / c);
    ll need  = 0;
    rep(i,l) need += r[i];
    return need <= K;
}

int main(){
    cin >> N >> K;
    A.resize(N+1);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }

    set<ll> st;
    for(int i=1;i*i<=sum;i++){
        if(sum % i == 0){
            st.insert(i);
            st.insert(sum/i);
        }
    }
    ll ma = 1;
    for(auto it : st){
        if(C(it)){
            ma = max(ma,it);
        }
    }

    cout << ma << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    char a[11], b[11], c[11];
    scanf("%s %s %s", a, b, c);

    int a_last = -1, b_last = -1, i = 0;

    while(a_last==-1){
        if(a[i]=='\0'){
            a_last = i-1;
        }
        i++;
    }

    i = 0;

    while(b_last==-1){
        if(b[i]=='\0'){
            b_last = i-1;
        }
        i++;
    }

    if((a[a_last]==b[0]) && (b[b_last]==c[0])){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
import itertools


def is_integer(num):
    if isinstance(num, int):
        return True
    if isinstance(num, float):
        return num.is_integer()
    return False


n, d = map(int, input().split())
x = []
for _ in range(n):
    x.append(tuple(map(int, input().split())))

cnt = 0
for a, b in itertools.combinations(x, 2):
    if is_integer(sum([(ad - bd) ** 2 for ad, bd in zip(a, b)]) ** 0.5):
        cnt += 1

print(cnt)


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    res = (N+999)/1000*1000 - N;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3668
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    if(b==1){
        return 0;
    }

    if(a<=b){
        return b-a;
    }
    // b < a
    else{
        if(a%b==0){
            return 0;
        }else{
            ll m = a/b;
            ll target_b = b * (m+1);
            return target_b - a;
        }
    }
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);

    FOR(i, 0, N){
        ll a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    ll num = 0;
    for(int i=N-1; i>=0; i--){
        ll a = how_many_push(A[i] + num, B[i]);
        num += a;
    }

    p(num);
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;
using lli = long long int;

vector<lli> input(int N) { vector<lli> r(N); for (int i = 0; i < N; i++)cin >> r[i]; return r; }

int main() {
	lli N, W;
	cin >> N >> W;
	lli dp[110][100010];
	for (int i = 0; i < N; i++) {
		lli w, v;
		cin >> w >> v;
		for (lli x = 0; x <= W; x++) {
			if (x < w)dp[i + 1][x] = dp[i][x];
			else dp[i + 1][x] = max(dp[i][x], dp[i][x - w] + v);
		}
	}

	cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	ll N;
	cin >> N;
	multiset<ll,greater<ll>> s;
	REP(i, 0, N) {
		ll a;
		cin >> a;
		auto itr = s.upper_bound(a);
		if (itr == s.end()) s.insert(a);
		else {
			s.erase(itr);
			s.insert(a);
		}
	}
	PRI(s.size());
	return 0;
}




Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
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;}
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; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ll MAX_N = 100100;

ll memo[MAX_N];

ll rec(ll n){
	if(n==0) return 0;
	if(memo[n] != -1)return memo[n]; //計算済み
    

	ll res=n;//最大で1円玉n枚で支払えばよい
	
	for(ll i=1;i<=n;i*=6){
		res=min(res,rec(n-i)+1);
	}
	for(ll i=1;i<=n;i*=9){
		res=min(res,rec(n-i)+1);
	}
	
	return memo[n] = res;//メモしながらリターン

}	

int main(){
    ll N; cin>>N;
	
	rep(i,MAX_N) memo[i]=-1;
	cout<<rec(N)<<endl;
}

Measured memory_bytes: 4096
N, K = map(int, input().split())
A = [0 for _ in range(N)]

for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        j -= 1
        A[j] += 1

ans = 0

for a in A:
    if a == 0:
        ans += 1

print(ans)




Measured memory_bytes: 9184
double P[102][101];L[101],B[101],N,T,l,b,t,n,k;main(x){for(;scanf("%d%d%d%d",&N,&T,&l,&b),N;printf("%f\n",P[T][N])){
for(n=0;n<=N;n++)for(L[n]=B[n]=t=0;t<=T;t++)P[t][n]=0;
for(;l--;)scanf("%d",&x),L[x]=1;
for(;b--;)scanf("%d",&x),B[x]=1;
for(P[t=0][0]=1;t<T;P[t+1][N]+=P[t][N],t++)for(n=0;n<N;n++)for(k=0;++k<7;)x=n+k,x=B[x=x>N?2*N-x:x]?0:x,P[t+1+L[x]][x]+=P[t][n]/6;
}exit(0);}

Measured memory_bytes: 716
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int l,a,b,c,d;
    cin>>l>>a>>b>>c>>d;
    cout<<l-max(ceil(double(a)/c),ceil(double(b)/d))<<endl;
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc086_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string a, b;
  cin >> a >> b;

  string ab = a + b;
  int c = stoi(ab);
  int sq = sqrt(c);

  cout << (sq * sq == c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

using namespace std;

int wall[64][64][4];

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

enum Dir{
  DOWN  = 0,
  RIGHT = 1,
  LEFT  = 3,
  UP    = 2
};

int ix, iy;
int ox, oy;
int h, w;

inline int mkid(int x, int y){ return w * y + x; }
inline int getX(int id){ return id % w; }
inline int getY(int id){ return id / w; }

int bfs(){
  queue<int> q;
  vector<int> memo(h * w, -1);

  memo[mkid(ix, iy)] = 0;
  q.push(mkid(ix, iy));

  while(q.size()){
    int id = q.front(); q.pop();
    int x = getX(id);
    int y = getY(id);

    if(x == ox && y == oy)
      return memo[id];

    REP(i,4){
      int xx = x + _dx[i];
      int yy = y + _dy[i];
      int ii = mkid(xx, yy);
      if(ISIN(xx, yy, w, h) &&
	 memo[ii] == -1     &&
	 wall[y][x][i] == 0){
	memo[ii] = memo[id] + 1;
	q.push(ii);
      }
    }
  }

  return -1;
}


int main(){
  w = getInt();
  h = getInt();

  int n = getInt();

  REP(i,n){
    int sx = getInt();
    int sy = getInt();
    int dx = getInt();
    int dy = getInt();

    if(sx > dx) swap(sx, dx);
    if(sy > dy) swap(sy, dy);

    if(sx == dx){
      for(int y = sy; y < dy; y++){
	wall[y][sx - 1][RIGHT] = 1;
	wall[y][sx    ][LEFT]  = 1;
      }
    }else{
      for(int x = sx; x < dx; x++){
	wall[sy - 1][x][UP]   = 1;
	wall[sy    ][x][DOWN] = 1;
      }
    }
  }

  ix = getInt();
  iy = getInt();
  ox = getInt();
  oy = getInt();
  
  int d = bfs();
  
  int ans = 0;
  REP(i,h) REP(j,w){
    if(i + 1 < h && wall[i][j][UP] == 0){
      wall[i][j][UP] = 1;
      wall[i + 1][j][DOWN] = 1;
      ans = max(ans, bfs() - d);
      wall[i][j][UP] = 0;
      wall[i + 1][j][DOWN] = 0;
    }
    if(j + 1 < w && wall[i][j][RIGHT] == 0){
      wall[i][j][RIGHT] = 1;
      wall[i][j + 1][LEFT] = 1;
      ans = max(ans, bfs() - d);
      wall[i][j][RIGHT] = 0;
      wall[i][j + 1][LEFT] = 0;
    }
  }
  
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K; cin >> N >> K;
  vector<int> V(N); REP(i, N) cin >> V[i];

  ll ans = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0;  j <= K-i; ++j) {
      if (i+j > N) continue;

      vector<ll> vv;
      ll sum = 0;
      for (int l = 0; l < i; ++l) {
        vv.push_back(V[l]);
        sum += V[l];
      }

      for (int l = N-j; l < N; ++l) {
        vv.push_back(V[l]);
        sum += V[l];
      }

      // K-i-j 取り除ける
      sort(ALL(vv));

      for (int l = 0; l < K-i-j; ++l) {
        if (l >= vv.size()) break;
        if (vv[l] >= 0) break;
        sum -= vv[l];
      }

      ans = max(ans, sum);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.*;


public class Main {
	public static void main(String[] argv) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int[] tree = new int[n];
		for(int i = 0; i < n; i ++) {
			tree[i] = in.nextInt();
//			System.out.println(tree[i]);
		}
		for(int i = 0; i < n; i ++) {
			System.out.print("node " + (i+1) + ": key = " + tree[i] + ", ");
			if(i!=0)
			{
				System.out.print("parent key = " + tree[(int)Math.floor((i+1)/2)-1] + ", ");
			}
			if(2*(i+1)<=n)
			{
				System.out.print("left key = " + tree[2*(i+1)-1] + ", ");
			}
			if(2*(i+1)+1<=n)
			{
				System.out.print("right key = " + tree[2*(i+1)] + ", ");
			}
			System.out.println("");
		}
		in.close();
	}
}


Measured memory_bytes: 27156
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0) print(1);
    else if(b==0) print(2);
    else if(c==0) print(3);
    else if(d==0) print(4);
    else print(5);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <bitset>
using namespace std;

class UnionFindTree{
	typedef struct {
		int parent;
		int rank;
	}base_node;
	
	vector<base_node> node;
public:
	UnionFindTree(int n){
		node.resize(n);
		for(int i=0; i<n; i++){
			node[i].parent=i;
			node[i].rank=0;
		}
	}

	int find(int x){
		if(node[x].parent == x) return x;
		else{
			return node[x].parent = find(node[x].parent);
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}

	void unite(int x, int y){
		x = find(node[x].parent);
		y = find(node[y].parent);
		if(x==y) return;
		if(node[x].rank < node[y].rank){
			node[x].parent = y;
		}else if(node[x].rank > node[y].rank){
			node[y].parent = x;
		}else{
			node[x].rank++;
			unite(x,y);
		}
	}
};

int main_(){
	int n,m,p;
	//cin >> n >> m >> p;
	scanf("%d%d%d", &n,&m,&p);

	UnionFindTree uft(n);

	vector<int> u(m),v(m);
	vector<int> e(m);
	vector<vector<int>> g(n);
	//vector<int> g(n);
	for(int i=0; i<m; i++){
		//cin >> u[i] >> v[i];
		scanf("%d%d", &u[i],&v[i]);
		u[i]--; v[i]--;
		//g[u[i]] |= 1<<v[i];
		//g[v[i]] |= 1<<u[i];
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
		//e[i] = (1<<u[i]) | (1<<v[i]);
		uft.unite(u[i], v[i]);
	}
	bool connected = true;
	for(int i=1; i<n; i++){
		connected = connected && uft.same(0,i);
	}
	if(connected == false){
		printf("0.000000000000000000\n");
		return 0;
	}

	vector<int> edge_cnt(1<<n, 0);
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<m; j++){
			if((i>>u[j])&(i>>v[j])&1){
				edge_cnt[i]++;
			}
		}
	}

	vector<double> prob(1<<n, -1);
	prob[1] = 1;

	function<double(int)> dfs = [&](int s){
		if(prob[s] != -1) return prob[s];
		double res = 1.0;
		int s_ = s-1;
		for(int x=s_; x>=0; x=(x-1)&s_){
			int y = x|1;
			if(y==s) continue;
			double q = dfs(y);

			double tmp = 1.0;
			/*
			for(int i=0; i<m; i++){
				if( (((1<<u[i])&y) && ((1<<v[i])&(s^y))) or (((1<<v[i])&y) and ((1<<u[i])&(s^y))) ){
					tmp *= 0.01 * p;
				}
			}
			*/
			
			tmp = pow(0.01*p, edge_cnt[s] - edge_cnt[y] - edge_cnt[s^y]);

			res -= q * tmp;

			if(x==0) break;
		}
		return prob[s] = res;
	};

	double ans = dfs((1<<n)-1);
	printf("%.18f\n", ans);
	return 0;
}


int main(){
	auto start = clock();
	main_();
	//cerr << clock()-start << endl;
	return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    int n;
    long sum =0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int index, score;
        cin >> index >> score;
        cout << (sum - v[index - 1] + score) << endl;
    }
    return 0;
}



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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var L = vals[0];
        var R = vals[1];

        const int mod = 2019;
        var best = long.MaxValue;

        for (var i = L; i <= Math.Min(R, L + mod * 2); i++)
        {
            for (var j = i + 1; j <= Math.Min(R, L + mod * 2); j++)
            {
                best = Math.Min(best, (((i % mod) * (j % mod)) % mod));
            }
        }

        Console.WriteLine(best);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define FW freopen("data2.txt", "w", stdout);
//读入输出外挂，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

void slove(int quetion_num)
{
    string s;
    int ans = 0;
    cin >> s;
    for (auto i : s)
    {
        ans += (i - '0');
    }
    if (ans % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
}
int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove(num);
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
using namespace std;
int main() {
    int x, flag, cnt=0;
    cin >> x;
    int A[x];
    for ( int i = 0; i < x; i++ ){
        cin >> A[i];
    }
    flag = 1;
    while (flag){
        flag = 0;
        for ( int j = x-1; j > 0; j-- ){
            if ( A[j] < A[j-1] ){
                swap( A[j], A[j-1] );
                flag = 1;
                cnt += 1;
            }
        }
    }
    for ( int i = 0; i < x; i++ ){
        if ( i == x-1 ){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int T;

	cin >> T;

	for (int tc = 1; tc <= T; ++tc) {
		ll A, B, C, D;

		cin >> A >> B >> C >> D;

		if (B > D || A < B)
			cout << "No\n";
		else if (C >= B)
			cout << "Yes\n";
		else {
			// find if i will enter [0, C]
			if (A - (A / B) * B > C)
				cout << "No\n";
			else {
//				cout << "idk\n";
				ll g = __gcd(B, D);
				ll x = (A - C + g - 1) / g - 1;
				if (A - x * g < B)
					cout << "No\n";
				else
					cout << "Yes\n";
			}
		}
	}



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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


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

    cout<<(a-1)*(b-1)<<endl;


    return 0;
}

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

int main(void){

    string s;
    cin >> s;
    int n = s.size();
    int r = n%2;

    for (int i = 0; i < (n - r)/2; i++){
        if(s[2*i]=='L'||s[2*i+1]=='R'){
             cout << "No" << endl;
             return 0;
        }
    }
    if(r == 1){
        if(s[n-1] == 'L'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

#define all(v) v.begin(), v.end()
typedef long long ll;

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

    for(int i = 0; i <= 120; i++){
        ll w = pow(i, 5);
        for(int j = 0; j <= 120; j++){
            ll t = pow(j, 5);
            if(x == w - t){
                cout << i << " " << j << endl;
                return 0;
            }
            if(x == w + t){
                cout << i << " " << j * -1 << endl;
                return 0;
            }
            if(x == (w * -1) - t){
                cout << i * -1 << " " << j << endl;
                return 0;
            }
            if(x == (w * -1) + t){
                cout << i * -1 << " " << j * -1 << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3988
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double h;
	cin >> h;
	ll cnt = 1;
	ll ans = 1;
	while (h > 1) {
		cnt *= 2;
		ans += cnt;
		h = floor(h / 2);
	}
	cout << ans;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,k;
vector<int> G[2222];
P es[2222];
bool vis[2222];

int dfs(int v,int d){
	int res=0;
	vis[v]=true;
	if(d>k)res++;
	rep(i,G[v].size()){
		int nv=G[v][i];
		if(!vis[nv])res+=dfs(nv,d+1);
	}
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>k;
	rep(i,n-1){
		int a,b;
		cin>>a>>b; a--; b--;
		es[i].fi=a; es[i].se=b;
		G[a].pb(b); G[b].pb(a);
	}
	int res=INF;
	if(k%2==0){
		k/=2;
		rep(i,n){
			rep(j,n)vis[j]=false;
			minch(res,dfs(i,0));
		}
	}else{
		k=(k-1)/2;
		rep(i,n-1){
			rep(j,n)vis[j]=false;
			int v1=es[i].fi,v2=es[i].se;
			vis[v1]=true,vis[v2]=true;
			minch(res,dfs(v1,0)+dfs(v2,0));
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 512