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

int main()
{
    int h, k, w;
    cin >> h >> w >> k;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    int ret = 1e9;
    for (int i = 0; i < (1 << (h - 1)); i++) {
        int nb = 1 + __builtin_popcount(i);
        vector<int> cnt(nb);
        int tmp = __builtin_popcount(i);
        bool suc = false;
        for (int j = 0; j < w; j++) {
            int now = 0;
            for (int ii = 0; ii < h; ii++) {
                if (s[ii][j] == '1') cnt[now]++;
                if (i & (1<<ii)) now++;
            }
            if (*max_element(cnt.begin(), cnt.end()) > k) {
                if (suc) {
                    tmp = 1e9;
                    break;
                }
                tmp++;
                for (auto &x:cnt) x = 0;
                j--;
                suc = true;
                continue;
            }
            suc = false;
        }
        ret = min(ret, tmp);
    }
    cout << ret << "\n";
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

map<ll, int> primeFactorization(ll n)
{
    map<ll, int> primeFacMap;
    ll q = 2;
    while(q * q <= n)
    {
        while(n % q == 0)
        {
            n = n / q;
            if (primeFacMap.find(q) == primeFacMap.end())
            {
                primeFacMap[q] = 1;
            }
            else
            {
                primeFacMap[q]++;
            } 
        }
        q++;
    }
    if (n != 1) primeFacMap[n] = 1;

    return primeFacMap;
}

int main()
{
    ll A, B;
    cin >> A >> B;

    map<ll, int> primeFacMapA, primeFacMapB;
    primeFacMapA = primeFactorization(A);
    primeFacMapB = primeFactorization(B);
    primeFacMapA[1] = 1;
    primeFacMapB[1] = 1;
    ll ans = 0;
    REPV(iter, primeFacMapA)
    {
        if (primeFacMapB.find(iter->first) != primeFacMapB.end()) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), p(n), q(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}
	for (int i = 0; i < n; i++) {
		a[i] = i + 1;
	}
	int cnt = 0, x, y;
	do {
		cnt++;
		int cntp = 0, cntq = 0;
		for (int i = 0; i < n; i++) {
			if (p[i] == a[i])
				cntp++;
			if (q[i] == a[i])
				cntq++;
		}
		if (cntp == n)
			x = cnt;
		if (cntq == n)
			y = cnt;
	} while (next_permutation(a.begin(), a.end()));
	cout << abs(x - y);
	return 0;
}

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

int main(){
    int N;
    int ans = 0;
    cin >> N;
    while(N > 0){
        if(N%10 == 7){
            ans = 1;
        }
        N /= 10;
    }
    if(ans == 1) cout  << "Yes" << endl;
    else cout  << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(){
	double a,b,c,d,e,f;
	double x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		if(a!=0&&d!=0){
			y = (c/a-f/d)/(b/a-e/d);
			x = (c-b*y)/a;
		}else if(a==0&&d!=0){
			y = b/c;
			x = (f-e*y)/d;
		}else if(a!=0&&d==0){
			y = f/e;
			x = (c-b*y)/a;
		}
		printf("%4.3f %4.3f\n",x,y);
	}
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String s = n();

		if (s.contains("7")) {
			out(Y);

		} else {
			out(N);
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int> > pairs(N);
    for (int i = 0; i < N; i++){
        cin >> pairs[i].first;
        cin >> pairs[i].second;
        //cout << a[i] << b[i];
    }
    vector<pair<int, int> > array(N);

    for(int i=0;i<N;i++){
        cin >> array[i].first;
        cin >> array[i].second;
    }
    sort(pairs.begin(),pairs.end());
    sort(array.begin(),array.end());

    int count = 0;
    bool flag[N];
    for(int i=0;i<N;i++) flag[i] = false;

    for(int i=N-1;i>=0;i--){
        int min = 100000000;
        int min_id = 100000;
        for(int j=0;j<N;j++){
            if(flag[j]==false && pairs[i].first<array[j].first && pairs[i].second < array[j].second){
                if(min > array[j].second){
                    //cout << j << array[j].second <<"\n";
                    min = array[j].second;
                    min_id = j;
                }
            }

        }
        //cout << i << " " <<min_id <<"\n";
        if(min_id!=100000) {
            flag[min_id] = true;
            count++;
        }
    }
    cout << count <<"\n";

}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    List<Integer> p = new ArrayList<>(A);
    List<Integer> q = new ArrayList<>(B);
    List<Integer> r = new ArrayList<>(C);
    for (int i = 0; i < A; i++) p.add(sc.nextInt());
    for (int i = 0; i < B; i++) q.add(sc.nextInt());
    for (int i = 0; i < C; i++) r.add(sc.nextInt());
    sc.close();

    p.sort(Comparator.reverseOrder());
    q.sort(Comparator.reverseOrder());

    List<Integer> xyc = new ArrayList<>(X + Y + C);
    xyc.addAll(p.subList(0, X));
    xyc.addAll(q.subList(0, Y));
    xyc.addAll(r);
    xyc.sort(Comparator.reverseOrder());

    long ans = 0;
    for (int i : xyc.subList(0, X + Y)) ans += i;

    System.out.println(ans);
  }
}

Measured memory_bytes: 103320
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    if(n==1||m==1) cout<<1<<endl;
    else
    cout<<((m+1)/2)*((n+1)/2)+(m-(m+1)/2)*(n-(n+1)/2)<<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;
 
  int changePayed500yen = n % 500;
  int payed = changePayed500yen - a;
  if (payed <= 0) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] P = new int[N];
    for (int i = 0; i < N; i++) P[i] = sc.nextInt();
    sc.close();

    int min = P[0];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (min < P[i]) continue;
      min = P[i];
      ans++;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 66852
import java.util.*;

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

		String marbles = scanner.next();
		int count = 0;
		
		for (int i = 0; i < marbles.length(); i++) {
			if (marbles.charAt(i) == '1') {
				count++;
			}
		}

		System.out.println(count);
		
		scanner.close();
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000009;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	vector<int> fa;
	bool pr[60000];for(int i=2;i<=55555;i++)pr[i]=true;
	for(int i=2;i<=55555;i++){
		if(pr[i]){
			for(int j=i*2;j<=55555;j+=i){
				pr[j]=false;
			}
		}
	}
	for(int i=2;i<=55555;i++){
		if(pr[i]&&i%5==1){
			fa.push_back(i);
		}
	}
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cout<<fa[i];
		if(i!=n-1)cout<<" ";
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;

    int ans = 0;
    int cnt = 0;
    REP(i, N - 1) {
        if (A[i] >= A[i + 1]) {
            cnt++;
            chmax(ans, cnt);
        }
        else {
            chmax(ans, cnt);
            cnt = 0;
        }
    }

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

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
    [n, x] <- fmap read . words <$> getLine
    as     <- fmap read . words <$> getLine
    answer $ solve x as

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: Int -> [Int] -> Answer
solve x = inner 0 x
  where
    inner !n !k aas
      | null as   = n + m
      | otherwise = inner (n + m) (x + m - a) as
      where
        (a : as) = aas
        m = max 0 (a - k)


Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[1020],i,n,p,k,j,res=0;
    cin>>n>>k;

    for(i=0;i<n;i++)
        cin>>arr[i];


    sort(arr,arr+n);

    for(i=0;i<k;i++)
        res+=arr[i];

    cout<<res<<endl;




return 0;

}


Measured memory_bytes: 3576
#Candy Distribution Again
n,x = map(int, input().split())
s= list(map(int,input().split()))

s.sort()
s.reverse
ans=0
if s[0]>x:
    print(ans)
else :
    for i in s:
        x=x-i
        if x>=0:
            ans+=1
        else :
            break
    if x>0:
        ans-=1
    print(ans)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
      long long ans=100, x, flag=0;
      cin >> x;
      while(1)
      {
            ans=ans+(ans*(0.01));
            flag++;
            if (ans>=x)
            {
                  break;
            }
      }cout << flag << endl;
 	return 0;
}


Measured memory_bytes: 3648
object Main extends App {
  def isReachable(from: (Int, Int, Int), to: (Int, Int, Int)): Boolean = {
    val ((t1, x1, y1), (t2, x2, y2)) = (from, to)
    val (t, x, y) = (t2 - t1, math.abs(x1 - x2), math.abs(y1 - y2))
    x + y <= t && (t - x) % 2 == y % 2
  }

  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val (isReachableAll, _) =
    1.to(N).foldLeft(true -> (0: Int, 0: Int, 0: Int)) {
      case ((acc, from), _) =>
        val to = (sc.nextInt(), sc.nextInt, sc.nextInt)
        (acc && isReachable(from, to)) -> to
    }
  println(if (isReachableAll) "Yes" else "No")
}


Measured memory_bytes: 58604
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
       int n,cnt=0;
       double d;
       cin>>n>>d;
       for(int i=1;i<=n;++i){
         double x,y;
         cin>>x>>y;
         double sum=x*x;
         sum+=(y*y);
         sum=sqrt(sum);
         if(sum<=d){
            ++cnt;
         }
       }
       cout<<cnt<<endl;
    }
    return 0;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
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;
}
int N;
int memo[100010];

int f(int cu){
  if (cu == 0) return 0;
  if (memo[cu]) return memo[cu];

  int res = inf;

  chmin(res, f(cu - 1) + 1);

  int x = 6;
  while (x <= cu) {
    chmin(res, f(cu - x) + 1);
    x *= 6;
  }

  x = 9;
  while (x <= cu) {
    chmin(res, f(cu - x) + 1);
    x *= 9;
  }
  return memo[cu] = res;
}

int main(){
  cin >> N;
  cout << f(N) << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    for (int i = 0; i + m - 1 < n; i++)
    {
        for (int j = 0; j + m - 1 < n; j++)
        {
            bool f = true;
            for (int k = 0; k < m; k++)
            {
                for (int l = 0; l < m; l++)
                {
                    if (b[k][l] != a[i + k][j + l])
                        f = false;
                }
            }
            if (f)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  VI a(n);
  double sum=0;
  rep(i,n) {
    cin>>a[i];
    sum+=a[i];
  }

  double dev=sum/(4*m);
  int cnt=0;
  rep(i,n){
    if(dev<=a[i]){
      cnt++;
    }
  }

  if(cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  

}

Measured memory_bytes: 256
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def LIR_(n): return [LI_() for i in range(n)]
def D():
    n, m = LI()
    p = LI_()
    xy = LIR_(m)
    size = [1 for _ in range(n)]
    height = [1 for _ in range(n)]
    par = [i for i in range(n)]
    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def union(x, y):
        s1 = find(x)
        s2 = find(y)
        if s1 != s2:
            if height[s1] < height[s2]:
                par[s1] = s2
                size[s2] += size[s1]
                size[s1] = 0
            else:
                par[s2] = s1
                size[s1] += size[s2]
                size[s2] = 0
                if height[s1] == height[s2]:
                    height[s1] += 1
 
    for x,y in xy:
        union(x, y)
    ans = 0
    for i in range(n):
        if find(p[i]) == find(i):
            ans += 1
    
    print(ans)
D()


Measured memory_bytes: 117100
#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;
const int INF = 1000000;

signed main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
    }
    rep(i,n);
    sort(a.begin(), a.end());
    int count = 0;
    for (int i=0; i<n-2; i++) {
        for (int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (a[i] + a[j] <= a[k]) break;
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {

	ll n, k; cin >> n >> k;
	double ans = 0;
	for (ll i = 1; i <= n; i++) {
		ll tmp = i;
		ll cnt = 0;
		while (tmp < k) {
			tmp *= 2;
			cnt++;
		}
		ll q = n;
		while (cnt--) {
			q *= 2;
		}
		ans += (double)1 / q;
	}
	cout << fixed << setprecision(11) << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int DP[100005];
vector <int> G[100005], V;
int N;
void Read()
{
    cin >> N;
    for(int i = 1; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

void DFS(int node, int father)
{
    int cnt = 0, val = 0, S = 0;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        DFS(neighb, node);
        //Sz[node] += Sz[neighb];
        ++cnt;
        S = (S ^ (DP[neighb] + 1));
    }
    //if(cnt != 1)
        DP[node] = S;
}
int main()
{
    Read();
    DFS(1, 0);
    if(DP[1] == 0)
    {
        cout << "Bob\n";
    }
    else
        cout << "Alice\n";
    return 0;
}


Measured memory_bytes: 13952
import itertools
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
acc = [0] + list(itertools.accumulate([(x+1)/2 for x in p])) # 累積和を計算
 
ans = max(acc[i]-acc[i-k] for i in range(k, n+1)) # k番目からn番目まで計算
print(ans)

Measured memory_bytes: 25152
#include <iostream>
#define ll long long
using namespace std;

int main() {
	ll N;
	cin >> N;
	ll ans=1e14;
	for(ll i=1; i*i<=N; ++i){
		if(N%i==0){
			ans=min(ans, (i+N/i)-2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
es=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

from itertools import permutations
perm=permutations(range(1,n))
ans=0
for p in perm:
    newp=[0]+list(p)
    flg=True
    for i in range(n-1):
        if newp[i+1] not in es[newp[i]]:
            flg=False
            break
    if flg: ans+=1
print(ans)

Measured memory_bytes: 40304
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val AB = Array(M) { listOfInt(-1) }
    var ans = 0
    repeat(M) { n ->
        val uf = UnionFind(N)
        repeat(M) { m ->
            if (n != m) {
                val (a, b) = AB[m]
                uf.union(a, b)
            }
        }
        if (uf.size(0) < N) ans += 1
//System.err.println("$n: $ans ${uf.size(0)}")
    }
    println(ans)
}
class UnionFind(n: Int) {
    var rank: IntArray
    var par:  IntArray
    var size: IntArray
    init {
        this.rank = IntArray(n) { 0 }
        this.par  = IntArray(n) { it }
        this.size = IntArray(n) { 1 }
    }
    fun union(x: Int, y: Int): Boolean {
        var rx = this.root(x)
        var ry = this.root(y)
        if (rx == ry) return false
        if (this.rank[rx] < this.rank[ry]) {
            val w = rx
            rx = ry
            ry = w
        } else if (this.rank[rx] == this.rank[ry]) {
            this.rank[rx] += 1
        }
        this.par[ry] = rx
        this.size[rx] += this.size[ry]
        return true
    }
    fun find(x: Int): Int {
        if (this.par[x] == x) return x
        else {
            this.par[x] = this.find(this.par[x])
            return this.par[x]
        }
    }
    fun isSame(x: Int, y: Int) = this.root(x) == this.root(y)
    fun size(x: Int): Int = this.size[this.find(x)]
    fun root(x: Int): Int = this.find(x)
    fun unite(x: Int, y: Int) = this.union(x, y)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { Integer.parseInt(it) + d }
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 38116
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W,A,B = map(int,read().split())

X = np.zeros((H,W),np.int8)

X[:B,:A] = 1
X[B:,A:] = 1

print('\n'.join(''.join(row) for row in X.astype(str)))

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

int main(){

 
  string S;
  cin>>S;
  
  for(int i=0;i<S.length();i++){
  
    cout<<"x";
    
  }
  cout<<endl;
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;


int32_t main(){
INIT
cin>>n;
for(int i=1; i<=n; i++){
    cin>>a[i];
}
int cur=1000, st=0;

for(int i=1; i<=n; i++){
    cur+=st*a[i];
    st=0;
    if(a[i+1]>a[i]){
        st+=(cur/a[i]);
        cur%=a[i];
    }
}
cout<<cur;

return 0;
}



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

const int N = 305, mod = 1e9 + 7, inv2 = 500000004;
typedef long long ll;
ll n, d[N], f[N][N][2], fac[N], inv[N], ans, ff = 1;

void upd(ll &x, ll y) { x = (x + y) % mod; }

void init() {
    fac[0] = inv[0] = inv[1] = 1;
    rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
    rep(i, 2, n) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    rep(i, 2, n) inv[i] = inv[i] * inv[i - 1] % mod;
}

int main() {
    cin >> n;
    init();
    rep(i, 1, n) cin >> d[i], ff &= (d[i] == 2);
    if (ff) return printf("%lld\n", fac[n - 1] * inv2 % mod), 0;
    f[0][0][0] = 1;
    rep(i, 1, n) {
        rep(j, 0, i) {
            rep(k, 0, 1) {
                upd(f[i][j][k], f[i - 1][j][k] * inv[d[i] - 1] % mod);
                if (j && d[i] > 1)
                    upd(f[i][j][k], f[i - 1][j - 1][k] * inv[d[i] - 2] % mod);
                if (j && d[i] > 2 && k)
                    upd(f[i][j][1], f[i - 1][j - 1][0] * inv[d[i] - 3] % mod);
            }
        }
    }
    rep(i, 3, n - 1) upd(ans, f[n][i][1] * fac[n - i - 1] % mod * fac[i - 1] % mod * inv2 % mod);
    printf("%lld\n", ans);
    return 0;
}


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

using ll = long long;

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

    ll n,a,b;
    cin>>n>>a>>b;

    ll ans=n/(a+b);
    ans*=a;
    ans+=min(n%(a+b),a);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3624
open System

let isSubArray xs ys =
    let n, m = Array.length xs, Array.length ys
    let rec f i j =
        if i = n then true
        elif j = m then false
        elif xs.[i] = ys.[j] then f (i+1) (j+1)
        else f i (j+1)
    f 0 0

let n = stdin.ReadLine() |> int
let s = stdin.ReadLine().ToCharArray()

let a = List.sum [
    for i in ['0'..'9'] do
    for j in ['0'..'9'] do
    for k in ['0'..'9'] ->
    if isSubArray [| i; j; k |] s then 1 else 0 ]
 
printfn "%d" a

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

int main()
{
	int a, b; cin >> a >> b;
	
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
int n,u,v,cnt,head[N],f[N][2],to[N*2],nxt[N*2];
void adde(int u,int v){
	to[++cnt]=v;
	nxt[cnt]=head[u];
	head[u]=cnt;
}
void dfs(int pre,int u){
	f[u][1]=1;
	int v;
	for(int i=head[u];i;i=nxt[i]){
		v=to[i];
		if(v!=pre){
			dfs(u,v);
			f[u][1]+=min(f[v][0],f[v][1]);
			f[u][0]+=f[v][1];
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		adde(u,v);
		adde(v,u);
	}
	dfs(0,1);
	puts(n%2==0&&min(f[1][0],f[1][1])==n/2?"Second":"First");
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  string S;
  cin >> S;
  cin >> S;

  cout << "A" << S[0] << "C" << endl;

  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

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

		while (sc.hasNextLine() == true) {
			String[] acards = sc.nextLine().split(" ");
			String[] bcards = sc.nextLine().split(" ");

			int[] ac = new int[acards.length];
			int[] bc = new int[bcards.length];
			for (int i = 0; i < acards.length; i++) {
				ac[i] = Integer.parseInt(acards[i]);
				bc[i] = Integer.parseInt(bcards[i]);
			}
			
			int h = 0;
			int b = 0;
			for (int i = 0; i < ac.length; i++) {
				for (int j = 0; j < bc.length; j++) {
					if (ac[i] == bc[j]) {
						if (i == j) h++;
						else b++;
					}
				}
			}
			
			System.out.println(h + " " + b);
		}
	}
}

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
vector<double> p(200005);
int main() {
	ios;
	int n,k,i,l,r;

	long double s=0,t=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
	cin>>p[i];
	for(i=0;i<k;i++) s+=(p[i]+1)/2;
	t=s;
	// l=0,r=k-1;
	for(i=k;i<n;i++)
	{
		t=t+(p[i]+1)/2-(p[i-k]+1)/2;
		s=max(s,t);
	}
	cout << fixed << setprecision(8) << s;
}


Measured memory_bytes: 1792
import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]

N, K, Q = map(int, input().split())

points = np.array([K - Q for _ in range(N)])

for q in range(Q):
    A = int(input()) - 1
    points[A] +=1

for p in points:
    if p < 1:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 17128
from itertools import product

N, K = map(int, input().split())
D = map(int, input().split())
like_num = set(range(10)) ^ set(D)
length = len(str(N))

for i in range(length, length+2):
  for x in product(like_num,repeat=i):
        d=''.join(map(str,x))
        if int(d)>=N:
          print(d)
          exit()

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,k=0,l;
    char s[10000];
    gets(s);
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
                       k=1;
                        break;
        }

    }
    if(k==1)printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int l, r;
	cin >> l >> r;
	if (r - l + 1 >= 2019) {
		cout << 0 << '\n';
		return 0;
	}
	ll answer = inf;
	for (ll i = l; i <= r; ++i) {
		for (ll j = i + 1; j <= r; ++j) {
			answer = min(answer, i * j % 2019);
		}
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int fact[10004];
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int s;
	scanf("%lld", &s);
	long long int p = 1000000007;
	long long int ans = 0;
	long long int i;
	fact[0] = 1;
	for (i = 1; i < 10004; i++)
		fact[i] = fact[i - 1] * i % p;
	for (i = 1; i <= s / 3; i++)
		ans = (ans + comb(s - 3 * i + i - 1, i - 1, p)) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1812
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val s, t = sc.next()

    val ans =
      if (s == t.init) "Yes" else "No"

    println(ans)
  }

  def f(n: Int): Int = {
    if (n < 0) n + 360
    else if (n > 360) n % 360
    else n
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}


Measured memory_bytes: 55216
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF -1000000000000000000
#define N 1000000007
#define ll long long
using namespace std;

int main(){
    ll n;
    cin>>n;
    
    ll ans=1;
    ll ans1=1;
    ll ans2=1;
    
    for(ll i=0; i<n; i++){
        ans*=10;
        ans%=N;
        ans1*=9;
        ans1%=N;
        ans2*=8;
        ans2%=N;
    }
    
    if(ans-2*ans1+ans2>=0){
        ll p=ans-2*ans1+ans2;
        p%=N;
        cout<<p<<endl;
    }
    else{
        ll p=2*N+ans-2*ans1+ans2;
        p%=N;
        cout<<p<<endl;
    }
}

Measured memory_bytes: 3568
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]
ans = 0

for arr in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    arr = list(arr)
    for a, b, c, d in X:
        if arr[b - 1] - arr[a - 1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 73780
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll x=0,d=0,n,h,w,k,m,ans=0,ptr=0;
    string s,s1,s2;
    cin >> x;
    int i=1;
    while(x>d){
        d += i;
        i++;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


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

  for (int i=1;i<=n;i++) {
    if (i%3==0) cout << " " << i;
    else {
      int x=i;
      while (x) {
        if (x%10==3) {
          cout << " " << i;
          break;
        }
        x/=10;
      }
    }
  }

  cout << endl;

  return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>
int main() {
  int a, b, c, d, l, n, x, z;
  scanf("%d\n%d\n%d\n%d\n%d", &l, &a, &b, &c, &d);
  n = ceil((double)a / (double)c);
  x = ceil((double)b / (double)d);
  if(n >= x) {
    z = l - n;
  }else{
    z = l - x;
  }
  printf("%d\n", z);
  return 0;
}

Measured memory_bytes: 596
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#ドミノの並べ方は縦1個おきか(X)、2個横に並べるか(Y)のどちからをつなげていくしかない
#端から見ていけばXかYかで塗り方は定まる

n = int(input())
s1 = list(input())
s2 = list(input())
ans = 1
XY = 0
i,j=0,0
while  i<n:
    if s1[i] == s2[j]:
        if XY == "X":
            ans *= 2
            ans %= mod
            i +=1
            j +=1
        elif XY =="Y":
            i += 1
            j += 1
            XY ="X"
        else:
            ans *= 3
            ans %= mod
            i += 1
            j += 1
            XY ="X"
    else:
        if XY =="X":
            ans *= 2
            ans %= mod
            XY ="Y"
            i += 2
            j += 2
        elif XY =="Y":
            ans *= 3
            ans %= mod
            i += 2
            j += 2
        else:
            ans *= 6
            ans %=mod
            i += 2
            j += 2
            XY ="Y"
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>  // ver2.1.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  int n;
  cin >> s >> n;
  int l = s.size();
  Vi a(l);
  rep(i,0,l){
    a[i] = s[i]-'a';
  }
  int now = n;
  //Vout(a);
  
  rep(i,0,l){
    if(a[i]==0) continue;
    if(now >= 26-a[i]) {
      now -= 26-a[i];
      a[i] = 0;
    }
  }
  //Vout(a);
  a[l-1] += now;
  a[l-1] %= 26;
  
  rep(i,0,l){
    char c = 'a';
    c += a[i];
    cout << c;
  }
  cout << endl;
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[311][311][311];
string s;

int solve(int l, int r, int k)
{
	if(k<0) return -int(1e9);
	if(l>r) return 0;
	if(dp[l][r][k]>=0) return dp[l][r][k];
	if(l==r) return 1;
	int ans = max(solve(l,r-1,k),solve(l+1,r,k));
	ans=max(ans,solve(l+1,r-1,k-(s[l]!=s[r]))+2);
	return (dp[l][r][k]=ans);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>s; int k; cin>>k;
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,int(s.length())-1,k)<<'\n';
}


Measured memory_bytes: 117888
fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => {
            get().parse::<$t>().unwrap()
        };
        () => {
            get!(i64)
        };
    }

    let (k, n) = (get!(), get!(usize));
    let mut a = vec![];
    for _ in 0..n {
        a.push(get!());
    }

    let mut ans = (k - a[a.len() - 1]) + a[0];
    for i in 0..(n - 1) {
        ans = std::cmp::max(ans, a[i + 1] - a[i]);
    }

    println!("{}", k - ans);
}


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

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

    int N, M;
    cin >> N >> M;
    vector<bool> isAC(N);
    vector<int> waCount(N);
    for(int i = 0; i < M; i++)
    {
        int num;
        string result;
        cin >> num >> result;
        num--;
        if(result == "AC")
        {
            isAC.at(num) = true;
        }else{
            if(!isAC.at(num)){
                waCount.at(num)++;
            }
        }
    }
    int totalAC = 0;
    int totalWA = 0;
    for(int i = 0 ;i < N; i++)
    {
        if(isAC.at(i)){
            totalAC++;
            totalWA += waCount.at(i);
        }
    }
    cout << totalAC << " " << totalWA << endl;
    return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var raw_inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var A = raw_inputs[0];
            var B = raw_inputs[1];

            if(B % A == 0){
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(B - A);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
string s[2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s[0] >> s[1];
  FOR(i, 0, 2){
    map<char, char> m;
    FOR(j, 0, sz(s[0])){
      if(m.find(s[i][j]) != m.end() && m[s[i][j]] != s[1-i][j]){
        Yn(false);
        return 0;
      }
      m[s[i][j]] = s[1-i][j];
    }
  }
  Yn(true);
  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct edge{
	int from, to, cost;
};

template <size_t N>
class UnionFindTree{
	private:
		int parent[N];
		int rank[N];
		int size[N];
	public:
		UnionFindTree(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		void init(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		int find(int x){
			if(parent[x] == x) return x;
			else return parent[x] = find(parent[x]);
		}
		void unite(int x, int y){
			x = find(x); y = find(y);
			if(x == y) return;

			if(rank[x] < rank[y]){
				parent[x] = y;
				size[y] += size[x];
			}else{
				parent[y] = x;
				size[x] += size[y];
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
		int getSize(int x){
			return size[find(x)];
		}
};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}


int main(void){
	vector<edge> g;
	int V, E; cin >> V >> E;
	for(int i = 0; i < E; i++){
		int s, t, w; cin >> s >> t >> w;
		edge e = {s, t, w};
		g.push_back(e);
	}

	UnionFindTree<10000> uf;
	sort(g.begin(), g.end(), comp);
	ll res = 0;
	for(int i = 0; i < E; i++){
		int a = g[i].from, b = g[i].to;
		if(not uf.same(a, b)){
			uf.unite(a, b); res+= (ll) g[i].cost;
		}
	}

	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n; cin >> n;
  vi v(n), p(n,0); for(int& i: v) cin >> i;
  rep(i,1,n){
    p[i] = p[i-1] + abs(v[i]-v[i-1]);
    if(i > 1) p[i] = min(p[i], p[i-2] + abs(v[i] - v[i-2]));
  }
  cout << p[n-1] << "\n";
}


Measured memory_bytes: 3952
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
	     Scanner s=new Scanner(System.in);
    //int t=s.nextInt();
    String ss=s.next();
    if(ss.contains("7"))
    System.out.println("Yes");
    else
    System.out.println("No");
		//System.out.println("GfG!");
	}
}

Measured memory_bytes: 35740