akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            ReadInt(out n, out k);
            var H = ReadIntArray();
            int ans = H.Count(h => h >= k);
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 19296
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  ll n; cin>>n; double ans=0;
  rep(i,n){
  double a; cin>>a; ans+=1.0/a;
  }
  
 cout << fixed << setprecision(9)<<1.0/ans<<endl; 
}

Measured memory_bytes: 256
n=int(input())
lis=list(map(int,input().split()))
ans=0

for i in range(1,n-1):
      if (lis[i-1]<lis[i] and lis[i]<lis[i+1]):
            ans +=1
      elif (lis[i+1]<lis[i] and lis[i]<lis[i-1]):
            ans +=1


print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  string T;
  cin >> S >> T;
  int count;
  count = 0;
  for(int i = 0;i<S.size();i++){
  if(S.at(i)==T.at(i)){
  count++;
  }
  }
  cout << count << endl;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} comb(1000000);

mint perm(int n, int k){
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    int P, Q;
    P = (-X+2*Y);
    Q = (2*X-Y);
    if (P%3 != 0 || Q%3 != 0) {
        cout << 0 << "\n";
        return 0;
    } else {
        P /= 3;
        Q /= 3;
    }
    mint ans = comb(P+Q,P);
    cout << ans << "\n";
}

Measured memory_bytes: 15872
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;cin>>a>>b;
    if (a<=0 && b>=0) {
      ct("Zero");
      return 0;
    }
    if (a>0 && b>0) {
      ct("Positive");
      return 0;
    }
    if (a==b && a<0 && b<0) {
      ct("Positive");
      return 0;
    }
    if (abs((a+b))%2==1) {
      ct("Positive");
    } else {
      ct("Negative");
    }

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n=II()
	ans = 1
	while n >= ans:
		ans *= 2
	print(ans//2)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 300, M = N * N, INF = 0x3f3f3f3f;

struct E {
	int i, j, w;
} ee[M];

int aa[N][N], dd[N][N];

int main() {
	int n; cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			int w; cin >> w;
			aa[i][j] = w;
			dd[i][j] = INF;
			auto &e = ee[m++];
			e.i = i;
			e.j = j;
			e.w = w;
		}
	sort(ee, ee + m, [] (auto &e, auto &f) { return e.w < f.w; });
	long long ans = 0;
	for (int h = 0; h < m; h++) {
		auto &e = ee[h];
		int i = e.i, j = e.j, w = e.w;
		int d = dd[i][j];
		for (int k = 0; k < n; k++)
			d = min(d, dd[i][k] + dd[k][j]);
		if (d > w) {
			d = w;
			ans += w;
		}
		dd[i][j] = dd[j][i] = d;
		for (int k = 0; k < n; k++) {
			dd[i][k] = dd[k][i] = min(dd[i][k], d + dd[j][k]);
			dd[j][k] = dd[k][j] = min(dd[j][k], d + dd[i][k]);
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (aa[i][j] != dd[i][j]) {
				cout << "-1\n";
				return 0;
			}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5364
(defun mmp (n)
  (and (> n 0) (<= n 12)))

(defun solve (s)
  (let ((before (parse-integer (subseq s 0 2)))
        (after (parse-integer (subseq s 2 4))))
    (cond
      ((and (mmp before) (mmp after)) "AMBIGUOUS")
      ((mmp before) "MMYY")
      ((mmp after) "YYMM")
      (t "NA"))))

(defun main ()
  (format t "~A~%" (solve (read-line))))

(main)


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

int main(){
    int n, k;
    while(cin >>n >>k){
        if(n == 0 && k == 0) break;
        vector<int> s(k, 0), b(k);
        for(int i = 0; i < k; i++) cin >>s[i];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < k; j++){
                int tmp;
                cin >>tmp;
                b[j] += tmp;
            }
        }
        bool okFlg = true;
        for(int i = 0; i < k; i++){
            if(s[i] < b[i]){
                okFlg = false;
                break;
            }
        }
        if(okFlg) cout <<"Yes" <<endl;
        else cout <<"No" <<endl;
    }
    return 0;
}

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

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto&ai:a)cin>>ai;

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

}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 5e1 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int cover[N];
vector<pair<int, int>> g[N];
bool dfs(int v, int fi, int p, int idx){
    if(v == fi){
        return true;
    }
    for(auto to: g[v]){
        if(to.fr == p){
            continue;
        }
        if(dfs(to.fr, fi, v, idx)){
            cover[to.se] |= (1 << idx);
            return true;
        }
    }
    return false;
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 0; i < n - 1; i ++){
        int x, y;
        cin >> x >> y;
        g[x].push_back({y, i});
        g[y].push_back({x, i});
    }
    cin >> m;
    for(int i = 0; i < m; i ++){
        int x, y;
        cin >> x >> y;
        dfs(x, y, -1, i);
    }
    vector<long long> d(1 << m);
    d[0] = 1;
    for(int i = 0; i < n - 1; i ++){
        for(int mask = (1 << m) - 1; mask >= 0; mask --){
            d[mask | cover[i]] += d[mask];
        }
    }
    cout << d[(1 << m) - 1] << "\n";
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1e5+5;

int a[maxn], b[maxn], c[maxn];

int dp[maxn][4];

int n;

int solve(int cur, int st)
{
	if(cur == n+1) return 0;
	if(dp[cur][st] != -1) return dp[cur][st];
	int ans = -1e9;
	if(st != 0) ans = max(ans, a[cur]+solve(cur+1, 0));
	if(st != 1) ans = max(ans, b[cur]+solve(cur+1, 1));
	if(st != 2) ans = max(ans, c[cur]+solve(cur+1, 2));
	return dp[cur][st] = ans;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i<= n; i++)
	{
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	memset(dp, -1, sizeof dp);
	printf("%d\n", solve(1, 3));
}

Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<utility>
#include<iomanip>
#define mod 998244853 
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a, b;
    cin >> a >> b;
    if( a <= 9 && b <= 9)
        cout << a * b << '\n';
    else
        cout << "-1\n";
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 44

int A[N];

int main(){

  int x,i;
  A[0] = 1;
  A[1] = 1;

  scanf("%d",&x);

  if(x <= 1){
    printf("%d\n",A[x]);
  }
  else {
  for(i=2;i<=x;i++){
    A[i] = A[i-1] + A[i-2];
  }

  printf("%d\n",A[x]);
  }
  return 0;
}



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

vector<vector<pair<int, int>>> nodes(100000);
vector<long long> score(100000);
void f(int parent, int node) {
	for (auto e : nodes[node]) {
		if (e.first == parent) continue;
		score[e.first] = score[node] + e.second;
		f(node, e.first);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	
	int a, b, c;
	for (int i = 1; i < n; i++) {
		cin >> a >> b >> c;
		nodes[a - 1].push_back(make_pair(b - 1, c));
		nodes[b - 1].push_back(make_pair(a - 1, c));
	}

	int q, k;
	cin >> q >> k;
	score[k - 1] = 0;
	f(-1, k-1);
	int x, y;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		cout << score[x - 1] + score[y - 1] << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    ll offset = 0;
    rep(i,n) offset = 2*a[i]-offset;
    ll x = offset/2;
    rep(i,n) {
        cout << x << " ";
        x = 2*a[i] -x;
    }
    cout << endl;
    
}

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

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int K=sc.nextInt();
		int len[]=new int[N];
		for(int i=0;i<N;i++){
			len[i]=sc.nextInt();
		}
		Arrays.sort(len);
		int sum=0;
		for(int i=0;i<K;i++){
			sum+=len[N-1-i];
		}
		System.out.println(sum);
		
	}

}


Measured memory_bytes: 23764
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")  */
#include <bits/stdc++.h>
 
#define file ""
 
#define all(x) x.begin(), x.end()
 
#define sc second
#define fr first
 
#define pb push_back
#define mp make_pair

#define pss pair<line*, line*>
 
using namespace std;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
                                 
const ll inf = 1e18;
const int MOD = 1e9 + 7;

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

const int N = 5e5 + 5;
           
ll dp[N][5];

int main() {                
#ifdef Mask                                                         
  freopen(".in", 	"r", stdin);
  freopen(".out", "w", stdout);  
#endif
	ios_base :: sync_with_stdio(false);               
  cin.tie(nullptr); 	
  int n;
  cin >> n;
  ll a[n + 1], b[n + 1], c[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    for (int k = 0; k <= 3; k++)
    	dp[i][k] = -1e18;
  }	
  for (int i = 1; i <= n; i++) {
   	dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
   	dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
   	dp[i][3] = max(dp[i - 1][2], dp[i - 1][1]) + c[i];
  }
  cout << max({dp[n][1], dp[n][2], dp[n][3]});
	return 0;   
}



Measured memory_bytes: 6656
def vs(A):
    A = sorted(A)
    pA = list(map(lambda x: x % A[0], A))
    pA[0] = A[0]
    return list(filter(lambda x: x != 0, pA))


N = int(input())
A = list(map(int, input().split()))


spA = -1
sA = -2
while spA != sA:
    sA = sum(A)
    pA = vs(A)
    spA = sum(pA)
    A = pA

print(sum(A))


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

int main() {
  int N, x=0, xmax=0;
  string S;
  cin >> N;
  cin >> S;
  for (int i=0; i<N; i++){
    if(S.at(i)=='I'){
      x++;
      if(x>xmax){
        xmax=x;
      }
    }
    else x--;
  }
  cout << xmax << endl;
}

Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, m;
		cin >> n >> m;
		vector<string> a(n), b(m);
		rep(i, 0, n)
		cin >> a[i];
		rep(i, 0, m)
		cin >> b[i];
		// cout << a[0];
		bool ans = true;
		rep(i, 0, n - m)
		{
			rep(j, 0, n - m)
			{
				ans = true;
				ll x = 0;
				rep(l, i, i + m)
				{
					ll y = 0;
					rep(k, j, j + m)
					{
						// deba(a[l][k]);
						if (a[l][k] != b[x][y])
						{
							ans = false;
							break;
						}
						y++;
					}
					x++;
				}
				if (ans)
				{
					cout << "Yes";
					return 0;
				}

			}
		}
		if (ans)
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e5 + 5;
multiset<int,greater<int>> s[maxn];
int n , a[maxn];

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n;
    for(int i = 0 ; i < (1 << n) ; ++i){
        cin >> a[i];
        s[i].insert(a[i]);
    }
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < (1 << n) ; ++j){
            if((j >> i) & 1){
                for(int c : s[j ^ (1 << i)]){
                    s[j].insert(c);
                }
                while(s[j].size() > 2)s[j].erase(s[j].find(*s[j].rbegin()));
            }
        }
    }
    int res = 0;
    for(int i = 1 ; i < (1 << n) ; ++i){
        res = max(res , *s[i].begin() + (*++s[i].begin()));
        cout << res << '\n';
    }
}



Measured memory_bytes: 52096
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    String b = sc.next();
    
    if(a>=3200){
      System.out.println(b);
    }else{
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 23760
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

struct SCC{
	vector<vector<int>>G,rG;
	vector<bool>used;
	vector<int>vs;
	void addEdge(int x,int y){
		G[x].push_back(y);
		rG[y].push_back(x);
	}
	void dfs(int x){
		used[x]=true;
		for(int i:G[x])if(!used[i])dfs(i);
		vs.push_back(x);
	}
	vector<int>cmp;
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		for(int i:rG[v])if(!used[i])rdfs(i,k);
	}
	void scc(){
		fill(all(used),false);
		rep(i,len(G))if(!used[i])dfs(i);
		fill(all(used),false);
		int k=0;
		rev(i,len(vs))if(!used[vs[i]])rdfs(vs[i],k++);
	}
	SCC(int N):G(N),rG(N),used(N),cmp(N){}
};

int N,D;
int X[1005][2];
bool ng[1005][2];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>D;
	rep(i,N)cin>>X[i][0]>>X[i][1];
	SCC scc(2*N);
	rep(i,N)for(int j=i+1;j<N;j++)rep(k,2)rep(l,2){
		if(abs(X[i][k]-X[j][l])<D){
			scc.addEdge((1-k)*N+i,l*N+j);
			scc.addEdge((1-l)*N+j,k*N+i);
		}
	}
	scc.scc();
	rep(i,N){
		if(scc.cmp[i]==scc.cmp[i+N]){
			cout<<"No\n";return 0;
		}
	}
	cout<<"Yes\n";
	rep(i,N){
		cout<<X[i][scc.cmp[i]>scc.cmp[i+N]]<<"\n";
	}
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi l(k);
    vi r(k);
    REP(i, k) cin >> l[i] >> r[i];
    vi dp(n + 1, 0);
    dp[1] = 1;
    dp[2] = -1;
    REP1(i, n) {
        dp[i] += dp[i - 1];
        dp[i] %= 998244353;
        REP(j, k) {
            if (i + l[j] <= n) {
                dp[i + l[j]] += dp[i];
                dp[i + l[j]] %= 998244353;
            }
            if (i + r[j] + 1 <= n) {
                dp[i + r[j] + 1] -= dp[i];
                dp[i + r[j] + 1] += 998244353;
                dp[i + r[j] + 1] %= 998244353;
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;


int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x))%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    return res%mod;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll binomialCoeff(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+1];
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1 && a[i]%2==1)
            ans++;
    }
    cout<<ans;
	return 0;
}


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

int main(){
    long long int K;
    char s[110];
    int i;
    int length;

    scanf("%s", &s);
    scanf("%lld", &K);
    length = strlen(s);

    if(s[0] == '1' && K==1){
        printf("1");
    }else{
        for(i=0; i<length; i++){
            if(s[i] == '1'){
                K = K-1;
            }
            if(s[i] != '1'){
                break;
            }
            if(K == 0){
                break;
            }
        }
        printf("%c", s[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int donyoku(vector<vector<int>> &p, int ko, int c, int w){
    rep(i,c+1)rep(j,w) if (p[i][j] > ko) return 1000000;
    int ans = c;
    vector<int> f(c+1,0);
    int cnt = 0;
    while (cnt < w){
        rep(i,c+1) f[i] += p[i][cnt];
        rep(i,c+1){
            if (f[i] > ko){
                cnt--;
                ans++;
                rep(k,c+1) f[k] = 0;
                break;
            }
        }
        cnt++;
    }
    return ans;
}


int main() {
    int h, w, ko; cin >> h >> w >> ko;
    vector<vector<int>> maze(h, vector<int>(w));
    rep(i,h){
        string s; cin >> s;
        rep(j,w){
            int a = stoi(s.substr(j,1));
            maze[i][j] = a;
        }
    }
    int ans = 100000000;
    rep(i,1<<(h-1)){
        vector<int> ar(h);
        int c = 0;
        ar[0] = 0;
        rep(j,h-1){
            if (i>>j&1){
                c++;
            }
            ar[j+1] = c;
        }
        vector<vector<int>> p(c+1,vector<int>(w,0));
        rep(k,h){
            rep(l,w){
                p[ar[k]][l] += maze[k][l];
            }
        }
        ans = min(ans,donyoku(p,ko,c,w));
    }
    cout << ans << endl;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i, N) cin >> S[i];

  sort(S.begin(), S.end());

  string ans;
  rep(i, N) ans += S[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N == 7 || N == 5 || N == 3) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)


// 有向グラフでの閉路検出
// O(V+E)
const int NMAX = 1001010;
vector<int> G[NMAX];
vector<int> status(NMAX, 0);
vector<int> dp(NMAX, -1);
// 0:New, 1:Active, 2:Finished
// Activeは行きがけ順序、Finishedは帰り掛け順序

bool IsAcyclicDFS(int v){
    status[v] = 1;
    for(auto to:G[v]){
        if(status[to] == 1) return false;
        else if(status[to] == 0){
            if(IsAcyclicDFS(to) == false) return false;
        }
    }
    status[v] = 2;
    return true;
}

bool IsAcyclic(){
    for(int i=0; i<NMAX; ++i) status[i] = 0;
    for(int i=0; i<NMAX; ++i){
        if(status[i] == 0){
            if(IsAcyclicDFS(i) == false) return false; 
        }
    }
    return true;
}

int rec(int now){
    if(dp[now] != -1) return dp[now];

    int res = 1;
    for(auto to:G[now]){
        chmax(res, rec(to)+1);
    }
    return dp[now] = res;
}

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

    int n; scanf("%d", &n);
    vector< vector<int> > a(n, vector<int>(n-1, 0));
    for(int i=0; i<n; ++i) for(int j=0; j<n-1; ++j) { scanf("%d", &a[i][j]); --a[i][j]; }

    for(int i=0; i<n; ++i){
        for(int j=0; j<n-2; ++j){
            int s1 = i, t1 = a[i][j];
            int s2 = i, t2 = a[i][j+1];
            if(s1 > t1) swap(s1, t1);
            if(s2 > t2) swap(s2, t2);
            G[1000*s1 + t1].push_back(1000*s2 + t2);
        }
    }

    if(IsAcyclic() == false){
        cout << -1 <<  endl;
        return 0;
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            chmax(ans, rec(1000*i + j));
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 51200
n, k = map(int, input().split())


sunuke = [False] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        sunuke[a[j] - 1] = True

cnt = 0
for i in sunuke:
    if not i:
        cnt += 1
print(cnt)

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

static const int MAX = 100;

int bubbleSort(int A[MAX], int N){
	
	bool flag = true;
	int cnt = 0;
	while (flag){
		flag = false;
		for (int j = N - 1; j >= 1; j--){
			if (A[j] < A[j - 1]){
				int tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				flag = true;
				cnt++;
			}
		}
	}
	return cnt;	
}

int main()
{
	int N;
	int A[MAX];
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	int cnt = bubbleSort(A,N);
	for (int i = 0; i < N; i++){
		cout  << A[i];
		if (i + 1 < N){
			cout << " ";
		}
	}
	cout << endl;
	cout << cnt;
	cout << endl;


	return 0;
}

Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long arr[] = new long[n];
		HashMap<Long, Long> map = new HashMap<>();
		long sum = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
			sum += arr[i];
			if (!map.containsKey(arr[i]))
				map.put(arr[i], (long)1);
			else
				map.put(arr[i], map.get(arr[i]) + 1);
		}
		int q = sc.nextInt();
		while (q-- > 0) {
			long b = sc.nextLong();
			long c = sc.nextLong();
			if (map.containsKey(b)) {
				sum = sum - b * map.get(b) + c * map.get(b);
				long tmp = map.get(b);
				map.put(b, (long)0);
				if (!map.containsKey(c))
					map.put(c, tmp);
				else
					map.put(c, map.get(c) + tmp);
				System.out.println(sum);
			} else
				System.out.println(sum);

		}


	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 84124
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long K = scan.nextLong();
		int[] A = new int[N+1];
		boolean[] vst = new boolean[N+1];
		for (int i = 1; i < N+1; i++) {
			A[i] = scan.nextInt();
		}
		ArrayList<Integer> l = new ArrayList<>();
		int town = 1;

		while (vst[town] == false) {
			vst[town] = true;
			l.add(town);
			town = A[town];
		}

		int s = l.indexOf(town);

		if (K < s+1) {
		} else {
			K -= s;
			for (int i = 0; i < s; i++) {
				l.remove(0);
			}
			K %= l.size();
		}

		System.out.println(l.get((int)K));

	}
}


Measured memory_bytes: 61136
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 105;

int n,ans1,cur1;
int u[MAXN];
int v[MAXN];
int MAX[MAXN];

ll ans2;

bool G[MAXN][MAXN];

void dfs(int u,int fa,int d)
{
	cur1 = max(cur1,d);
	int cnt = 0;
	for (int i = 1;i <= n + 1;i++)
		if (G[u][i] && i != fa)
		{
			cnt++;
			dfs(i,u,d + 1);
		}
	MAX[d] = max(MAX[d],cnt);
}

void getans(int rt,int v)
{
	cur1 = 0;
	for (int i = 1;i <= n + 1;i++)
		MAX[i] = 1;
	dfs(rt,0,1);
	ll cur2 = 1;
	for (int i = 1;i <= cur1;i++)
		cur2 *= MAX[i];
	cur1 += v;
	if (cur1 < ans1)
	{
		ans1 = cur1;
		ans2 = cur2;
	}
	else if (cur1 == ans1 && cur2 < ans2)
		ans2 = cur2;
}

int main()
{
	scanf("%d",&n);
	for (int i = 1;i < n;i++)
	{
		scanf("%d%d",&u[i],&v[i]);
		G[u[i]][v[i]] = G[v[i]][u[i]] = 1;
	}
	ans1 = 1e9;
	ans2 = (1ll << 60) - 1;
	for (int i = 1;i <= n;i++)
		getans(i,0);
	for (int i = 1;i < n;i++)
	{
		G[u[i]][v[i]] = G[v[i]][u[i]] = 0;
		G[u[i]][n + 1] = G[n + 1][u[i]] = 1;
		G[v[i]][n + 1] = G[n + 1][v[i]] = 1;
		getans(n + 1,-1);
		G[u[i]][v[i]] = G[v[i]][u[i]] = 1;
		G[u[i]][n + 1] = G[n + 1][u[i]] = 0;
		G[v[i]][n + 1] = G[n + 1][v[i]] = 0;
	}
	printf("%d %lld\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define NOMINMAX
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = (int) 1e9;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.00001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n, c = 0;
	cin >> n;
	while (n--) {
		int a;
		cin >> a;
		if (a % 2) c++;
	}
	if (c % 2) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);

  int C[14], D[14], H[14], S[14];
  int i;
  for(i = 0; i < 14; ++i)
  {
    C[i] = 1;
    D[i] = 1;
    H[i] = 1;
    S[i] = 1;
  }


  char cardName;
  int cardNumber;
  for(i = 0; i < n; ++i)
  {
    scanf(" %c %d",&cardName ,&cardNumber);
    switch (cardName) {
      case 'S':
        S[cardNumber] = 0;
        break;
      case 'H':
        H[cardNumber] = 0;
        break;
      case 'C':
        C[cardNumber] = 0;
        break;
      case 'D':
        D[cardNumber] = 0;
        break;
    }
  }

  int j;
  for(i = 0; i < 4; ++i)
  {
    for(j = 1; j < 14; ++j)
    {
      if(i == 0 && S[j]){
        printf("S %d\n",j);
      }
      else if(i == 1 && H[j]){
        printf("H %d\n",j);
      }
      else if(i == 2 && C[j]){
        printf("C %d\n",j);
      }
      else if(i == 3 && D[j]){
        printf("D %d\n",j);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	ll a,b;
	char c;
	cin >> a >> c >> b;
	if(c == '+') cout << a+b << endl;
	else cout << a-b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int a,b,c,d;cin>>a>>b>>c>>d;
  while(true){
    c -=b;
    if(c<=0) {
      cout << "Yes" << endl;
      break;
    }
    a -=d;
    if(a<=0) {
      cout << "No" << endl;
      break;
    
    }
  
  }
  

  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n,-1);
  
  int x,y;
  for(int i=0; i<m; i++){
  	cin >> x >> y;
    if(a[x-1]==-1){
    	a[x-1]=y;
    }else if(a[x-1]!=y){
     	cout << -1 << endl;
        return 0;
    }
  }
  if (n!=1 && a[0]==0) {
    cout << -1 << endl;
    return 0;
  }
  if(n==3){
    cout << max(a[0],1)*100 + max(a[1],0)*10 + max(a[2],0) << endl;
  }else if(n==2){
  	cout << max(a[0],1)*10 + max(a[1],0) << endl;
  }else{
    cout << max(a[0],0) << endl;
  }
}

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

namespace ABC042
{
    class C
    {
        static void Main(string[] args)
        {
            //input
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int K = input[1];
            int[] D = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] D2 = Enumerable.Range(0, 10).Where(x => !D.Contains(x)).ToArray();

            //Console.WriteLine(string.Join(",", D2));
            //Console.WriteLine(N.ToString().Length);

            //Nの桁数回繰り返す
            int len = N.ToString().Length;
            //int res = 0;
            int n = 0;

            for (int i = N; i < 10 * N; i++)
            {
                bool isOK = true;
                n = i;
                string s = n.ToString();
                for (int j = 0; j < s.ToString().Length; j++)
                {
                    if (D.Contains(int.Parse(s[j].ToString()))) { isOK = false; break; }
                }
                if (isOK) break;
            }
            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 15432
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c = 1, d, e;
	cin >> a >> b;
	if (a > 0) {
		cout << "Positive" << endl;
	}
	else if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if (b < 0 && (a - b) % 2 == 0) {
		cout << "Negative" << endl;
	}
	else {
		cout << "Positive" << endl;
	}
	cin >> e;
}

Measured memory_bytes: 256
MOD = 10**9 + 7


def main():
    import sys
    input = sys.stdin.buffer.readline
    _ = int(input())
    A = [int(i) for i in input().split()]

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    def lcm(x, y):
        return x*y//gcd(x, y)

    L = A[0]
    for a in A[1:]:
        L = lcm(L, a)
    L %= MOD
    ans = 0
    for a in A:
        ans += L*pow(a, MOD-2, MOD)
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41708
import sys
from io import StringIO
import unittest
import queue


def resolve():
    # ★get input
    h, w = map(int, input().split())

    grid = [["" for i in range(w)] for j in range(h)]

    for i in range(h):
        line = input()
        for j in range(w):
            grid[i][j] = line[j:j+1]

    # ★exec
    # 最短経路を求める
    distance = [[-1 for i in range(w)] for j in range(h)]
    que = queue.Queue()

    # スタート地点の情報を設定
    que.put([0, 0])
    distance[0][0] = 0

    while not que.empty():

        now = que.get()

        # 上下左右のマスを確認
        for move_y, move_x in ((1, 0), (-1, 0), (0, 1), (0, -1)):

            # 迷路の範囲外なら何もしない
            target = [now[0] + move_y, now[1] + move_x]
            if not h > target[0] >= 0 or not w > target[1] >= 0:
                continue

            # 黒塗りされているなら何もしない
            if grid[target[0]][target[1]] == '#':
                continue

            # 距離が設定済みなら何もしない
            if not distance[target[0]][target[1]] == -1:
                continue

            # キューに追加
            que.put(target)

            # 最短距離を設定
            distance[target[0]][target[1]] = distance[now[0]][now[1]] + 1

    # 最短経路までの距離を取得
    shortest_distance = distance[h-1][w-1]
    # 到達不可能の場合、ここで終了
    if shortest_distance == -1:
        print("-1")
        return

    # 塗りつぶしできないマスの個数を取得
    # 初期値1(スタート地点は塗りつぶし不可能であるため
    not_repaint_count = 1
    # 最初黒で塗られているマスの数を加算
    for i in range(h):
        not_repaint_count += grid[i].count("#")

    # 最初白のマス - 最短経路 = 塗りつぶしできるマス数。
    a = len(grid) * len(grid[0]) - not_repaint_count - shortest_distance
    print(a)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3
..#
#..
..."""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10 37
.....................................
...#...####...####..###...###...###..
..#.#..#...#.##....#...#.#...#.#...#.
..#.#..#...#.#.....#...#.#...#.#...#.
.#...#.#..##.#.....#...#.#.###.#.###.
.#####.####..#.....#...#..##....##...
.#...#.#...#.#.....#...#.#...#.#...#.
.#...#.#...#.##....#...#.#...#.#...#.
.#...#.####...####..###...###...###..
....................................."""
        output = """209"""
        self.assertIO(input, output)

if __name__ == "__main__":
    resolve()

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

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	if (a < 0)
	{
		cout << -a * c + d + b * e << endl;
	}
	else
	{
		cout << (b - a) * e << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
"""

https://atcoder.jp/contests/cf17-final/tasks/cf17_final_e

回文をちゃんと定義しよう？
左の文字を何回変化させたら右になるか、をxとする
iを並べた時、対象の部分の和は26(の倍数)でなくてはならない
ただし、xの列が奇数調なら真ん中は0

abba なら
1,0,25

すると、l,rは2点を更新するだけになる
index l-1を+1し、rを-1する(mod26せよ,1-origin)
左右反転した部分の和を配列yとしてもつ(mod26)
すると、配列の2つの部分に+1,-1する操作を好きな回数だけ行って全て
26の倍数にせよという問題になる。

+→-の有向グラフで考える
まず、連結成分ごとに全てのノードの初期値の総和が26の倍数で無いなら不可能
そうでなければ可能(端から合わせていけば絶対つじつまが合うため)
解けたのでは？
あ、ただし、-1 or len(S-1)とリンクしてる連結成分は26の倍数でなくてもよい
1-indexedのほうがいいか？
0 or len(S)とリンクしてる連結成分は26の倍数でなくてもよい

"""
import sys
sys.setrecursionlimit(200000)
alp = "abcdefghijklmnopqrstuvwxyz"
ad = {}
for i in range(26):
    ad[alp[i]] = i

S = input()
x = []

for i in range(len(S)-1):
    x.append((ad[S[i+1]]-ad[S[i]]) % 26)

y = [0]
for j in range((len(x)+1)//2):

    j2 = len(x)-1-j

    if j != j2:
        y.append(x[j]+x[j2])
    else:
        y.append(x[j])

#print (x,y)
N = int(input())

lis = [ [] for i in range(len(y)) ] #連結リスト
for loop in range(N):
    
    l,r = map(int,input().split())
    l -= 1

    l = min( l , len(x)+1-l )
    r = min( r , len(x)+1-r )

    lis[l].append(r)
    lis[r].append(l)

#print (lis)

def dfs(v):
    ret = y[v]
    visit[v] = True
    for nex in lis[v]:
        if not visit[nex]:
            ret += dfs(nex)
    return ret

visit = [False] * len(lis)
ans = "YES"
for i in range(len(lis)):

    if visit[i]:
        continue
    rec = dfs(i)
    if i != 0 and rec % 26 != 0:
        ans = "NO"
        break

print (ans)

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


int main()
{
   int a,b;
   int keta = 1;
   int i;
  
   cin >> a >> b;
   while(!cin.eof())
     {
       a+=b;
       while(a>=10){
         a/=10;
         keta++;
       }
       cout << keta << endl;
       cin >> a >> b;
       keta = 1;
     }
  
   return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int mx1=-1000000000,b,mx2=-1000000000;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx1=max(mx1,a[i]);
		if(mx1==a[i]){
			b=i;
		}
	}
	for(int i=0;i<n;i++){
		if(i!=b){
			mx2=max(mx2,a[i]);
		}
	}
	for(int i=0;i<n;i++){
		if(i!=b){
			cout<<mx1<<endl;
		}
		else{
			cout<<mx2<<endl;
		}
	}
} 

Measured memory_bytes: 2432
x,y,a,b,c = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
p = sorted(P,reverse=True)
q = sorted(Q,reverse=True)
r = sorted(R,reverse=True)
V = p[0:x] + q[0:y] + r
v = sorted(V,reverse=True)
print(sum(v[0:x+y]))

Measured memory_bytes: 24368