akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



signed main(){
    int n,k;
    cin >> n >> k;
    vector<int> z;
    vector<int> o;
    string s;
    cin >> s;
    int renzoku = 1;
    char s_ren = '0';
    REP(i,n){
        if(i==0){
            s_ren = s[i];
        }
        else if(s[i] == s_ren){
            renzoku++;
        }
        else{
            if(s_ren == '0'){
                z.push_back(renzoku);
                s_ren = '1';
            }
            else{
                o.push_back(renzoku);
                s_ren = '0';
            }
            renzoku = 1;
        }
    }
    if(s_ren == '0'){
        z.push_back(renzoku);
    }
    else{
        o.push_back(renzoku);
    }
    if(z.size() == 0 || z.size() <= k){
        cout << n << endl;
        return 0;
    }
    int ans = 0;
    if(s[0] == '0'){
        int x = 0;
        REP(i,k){
            x += z[i] + o[i];
        }
        ans = x;
        z.erase(z.begin());
    }
    if(s[n-1] == '0'){
        int x = 0;
        REP(i,k){
            x += z[z.size()-1-i] + o[z.size()-1-i];
        }
        ans = max(ans,x);
        z.erase(z.begin() + z.size() - 1);
    }
    REP(i,z.size()-k+1){
        int x = 0;
        REP(j,k){
            x += z[i+j] + o[i+j];
        }
        x += o[i+k];
        ans = max(ans,x);
    }

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



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 1404
"""
>>> main(3, 2, [[2, [1, 3]], [1, [3]]])
1
"""


def main(n: int, k: int, d_a: list):
    snuke = [[] for _ in range(n)]

    for d, a in d_a:
        for _a in a:
            snuke[_a - 1].append(d)

    ans = 0
    for s in snuke:
        if len(s) == 0:
            ans += 1

    print(ans)


if __name__ == "__main__":
    n, k = map(int, input().split())

    d_a = [[int(input()), list(map(int, input().split()))] for _ in range(k)]

    main(n, k, d_a)


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = (int)inputArray[0];

			var sixJumps = new List<int>();
			var n = 6;
			while (n<=100000) {
				sixJumps.Add(n);
				n *= 6;
			}

			var nineJumps = new List<int>();
			var m = 9;
			while (m <= 100000) {
				nineJumps.Add(m);
				m *= 9;
			}

			var dp = new int[N + 1];
			dp[0] = 0;

			for (int i = 1; i <= N; i++) {
				var count = dp[i - 1] + 1;

				foreach (var s in sixJumps) {
					if (s > i) {
						continue;
					}

					count = Math.Min(count, dp[i - s]+1);
				}

				foreach (var nine in nineJumps) {
					if (nine > i) {
						continue;
					}
					count = Math.Min(count, dp[i - nine]+1);
				}

				dp[i] = count;
			}



			//答えの出力
			var ans = dp[N];
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28484
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
 
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main(){
	int n;cin>>n;
	cout<<24+(24-n)<<endl;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }
    queue<pair<int, int>> que;
    que.push({0, 0});
    vector<vector<int>> dist(H, vector<int>(W, 1e9));
    dist[0][0] = 0;
    while (!que.empty()) {
        int h = que.front().first;
        int w = que.front().second;
        que.pop();
        if (h + 1 < H && A[h + 1][w] == '#') {
            dist[h + 1][w] = dist[h][w] + 1;
            que.push({h + 1, w});
        }
        if (w + 1 < W && A[h][w + 1] == '#') {
            dist[h][w + 1] = dist[h][w] + 1;
            que.push({h, w + 1});
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (dist[h][w] == 1e9 && A[h][w] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    for (int h0 = 0; h0 < H; h0++) {
        for (int w0 = 0; w0 < W; w0++) {
            for (int h1 = 0; h1 < H; h1++) {
                for (int w1 = 0; w1 < W; w1++) {
                    if (h0 == h1 && w0 == w1) {
                        continue;
                    }
                    if (dist[h0][w0] == 1e9 || dist[h1][w1] == 1e9) {
                        continue;
                    }

                    if (dist[h0][w0] == dist[h1][w1]) {
                        cout << "Impossible" << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << "Possible" << endl;
}


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

int main(){
  int n; cin >> n;
  int sum1 = 0, sum2 = 0;
  for(int i = 0; i < n; i++){
  	int x; cin >> x;
  	sum1 += x;
    sum2 += x*x;
  }
  
  int ans1 = sum2 + n*(sum1/n)*(sum1/n) - 2*sum1*(sum1/n);
  int ans2 = sum2 + n*(sum1/n+1)*(sum1/n+1) - 2*sum1*(sum1/n+1);
  
  int ans = min(ans1, ans2);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  cout<<n/500*1000+(n-(n/500*500))/5*5<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>n;--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define pop pop_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf 1e18
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define bye return

int main()
{
    ll N,i;
    cin>>N;

    ll A[N];
    map<ll,ll>MAP;

    fr(i,1,N)
    {
        cin>>A[i];
        MAP[A[i]]++;
    }   
    
    //c=0;

    for(i=1;i<=N;i++)
    {   
        cout<<MAP[i]<<" ";
    }
    cout<<endl;
    bye 0;

}

Measured memory_bytes: 17688
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)

int main()
{
        IO;
        int i, j, n, m, k, l, mx=0;
        cin>>n>>m;
        j = (n*(n-1))/2+(m*(m-1))/2;
        cout<<j<<endl;
    return 0;
}



Measured memory_bytes: 256
H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
A=[list(map(int,input().split())) for _ in range(H)]

mincost=[0 for i in range(10)]

for i in range(10):
    if i!=1:
        res = {i:0}
        path = [(j,c[i][j]) for j in range(10) if j not in res.keys()]
        while 1 not in res.keys():
            path.sort(key=lambda x:x[1])
            node,cost=path[0]
            res[node]=cost
            path = [p for p in path if p[0] not in res.keys()]
            path += [(j,cost+c[node][j]) for j in range(10) if j not in res.keys()]
        mincost[i]=res[1]

ans=0
from itertools import product
for i,j in product(range(H),range(W)):
    if A[i][j]!=-1:
        ans+=mincost[A[i][j]]
print(ans)


Measured memory_bytes: 42844
#include<stdio.h>
int D[7][7]={{},
{0,0,4,2,5,3,0},
{0,3,0,6,1,0,4},
{0,5,1,0,0,6,2},
{0,2,6,0,0,1,5},
{0,4,0,1,6,0,3},
{0,0,3,5,2,4,0}},G[7],N,i,t,f;
int sc(int d)
{
    int i;
    for(i=1;i<=6;i++)
        if(G[i]==d)
            return i;
}
int main()
{
    for(i=1;i<7;i++)scanf("%d",G+i);
    scanf("%d",&N);
    for(;N--;)
    {
        scanf("%d%d",&t,&f);
        printf("%d\n",G[D[sc(f)][sc(t)]]);
    }
    return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int> P;

bool judge(P a,P b){
    if(a.first > b.first) return true;
    return false;
}

int n,m,a,b;
vector<P> bs;
int main(){
    cin >> n >> m;
    rep(i,m) cin >> a >> b, bs.pb(mp(a,b));
    sort(ALL(bs),judge);
    int br = n, ct = 0;
    rep(i,m){
        if(bs.at(i).second <= br){
            br = bs.at(i).first;
            ct++;
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 1400
<?php
list ($a, $b, $c) = fscanf(STDIN, '%d %d %d');

$pair = 0;
if ($a === $b) {
    ++$pair;
}
if ($b === $c) {
    ++$pair;
}
if ($a === $c) {
    ++$pair;
}

echo $pair === 1 ? 'Yes' : 'No';


Measured memory_bytes: 4604
#include<iostream>
#include<cstdio> 
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout) 
typedef long long ll;
const ll mod=998244353;
const ll INF=0x3f3f3f3f;
const ll maxn=1e6+5;
const double pi = acos(-1.0);
using namespace std;
int main(){
	ll n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int count = 0;
		for(int i = 1; i < list.size(); i++) {
			if(list.get(i) == list.get(i-1)) {
				
			}else{
				count++;
			}
		}
		System.out.println(count + 1);
	}

}


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

using namespace std;

int n,m,k;
int c[3010][3010];
long long dp[3010][3010][4];

long long f(int x, int y, int cur) {
    if(x == n - 1 and y == m - 1) {
        if(cur < 3) return c[x][y];
        else return 0;
    }

    long long &ans = dp[x][y][cur];
    if(ans != -1) return ans;
    ans = -1e15;

    if(cur < 3) {
        if(y + 1 < m) ans = max(ans, f(x, y + 1, cur + 1) + c[x][y]);
        if(x + 1 < n) ans = max(ans, f(x + 1, y, 0) + c[x][y]);
    }
    if(y + 1 < m) ans = max(ans, f(x, y + 1, cur));
    if(x + 1 < n) ans = max(ans, f(x + 1, y, 0));
    return ans;
}

int main() {

    memset(dp, -1, sizeof dp);
    cin >> n >> m >> k;

    for (int i = 0; i < k; ++i) {
        int x,y,w;
        cin >> x >> y >> w;
        x--,y--;
        c[x][y] = w;
    }

    cout << f(0,0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 322520
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int H, W;
        char a[110][110];
        int couh=0,couw=0;
        int counth[110], countw[110];

        cin >> H >> W;

        for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                        cin >> a[i][j];
                }
        }

        for(int i=0; i<H; i++){
                bool fl=true;
                for(int j=0; j<W; j++){
                        if(a[i][j]!='.') fl=false;
                }
                if(!fl){
                        counth[couh]=i;
                        couh++;
                }
        }

        for(int i=0; i<W; i++){
                bool fl=true;
                for(int j=0; j<H; j++){
                        if(a[j][i]!='.') fl=false;
                }
                if(!fl){
                        countw[couw]=i;
                        couw++;
                }
        }

        for(int i=0; i<couh; i++){
                for(int j=0; j<couw; j++){
                        cout << a[counth[i]][countw[j]];
                }
                cout <<endl;
        }
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
 
  public static void main(String args[]) {
   
    Scanner sc = new Scanner(System.in);
    int length = sc.nextInt();
    int[] data = new int[length];
    for (int a=0; a<length; a++) {
       data[a] = sc.nextInt();
    }
   
    int count = 0;
    int i = 0;
    int min = data[0];
    
    for (int b=0; b<length; b++) {
      i = data[b];
      
      if (min >= i) {
        count++;
        min = i;
      }
    }
    
    System.out.println(count);
   

    
  }
}

Measured memory_bytes: 60260
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            
            
            var P = cin.ReadIntArray(N);
            int num = 0;
            int pmin = 0;

            for (int i = 0; i < N; i++)
            {
                if (P[pmin] >= P[i])
                {
                    pmin = i;
                    num++;
                }
            }
            
            WriteLine(num);

            /* ex2
            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var str = "";
            if (N >= M)
            {
                for (int i = 0; i < N; i++)
                {
                    str += M.ToString();
                }
            }
            else
            {
                for (int i = 0; i < M; i++)
                {
                    str += N.ToString();
                }
            }
            WriteLine("{0}", str);
            */
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

const int N = 105;

int n, x, ans;
bool vis[N];

int main() {
	cin>>x>>n;
	for(int i = 1; i <= n; i++) {
		int u;
		cin>>u;
		vis[u] = 1;
	}
	for(int i = 0; i <= 101; i++)
	    if(!vis[i] && abs(ans - x) > abs(x - i)) ans = i;
    cout<<ans<<endl;  
	return 0;
}

Measured memory_bytes: 3628
kai = []
while True :
  n = int(input())
  if n == 0 :
    break
  s = list(map(int,input().split()))

  m = sum(s)/(len(s))
  
  
  a = [(i-m ) for i in s]
 
  a0 = [r**2 for r in a]
  
  a1 = sum(a0)
  
  a2 = (a1/(len(s)))**(1/2)
  kai.append(a2)
  
  
for k in kai :
  print(k)


Measured memory_bytes: 5684
#include <stdio.h>

#define N 100

int compare (
  const char  * m,
  const char  * s
  )
{
  for ( ; *m != '\0'; ++m, ++s )
  {
    if ( *m == '*' || *m == *s )  continue ;

    return ( 0 );
  }

  return ( 1 );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    struct
    {
      char  cond[ 12 ];
      int   value;
    } d[ N ];
    char src[ 12 ];
    int res = 0;
    int n, m;

    scanf ( " %d %d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( " %s %d", d[ i ].cond, &d[ i ].value );
    }

    for ( j = 0; j < m; ++j )
    {
      scanf ( " %s", src );
      for ( i = 0; i < n; ++i )
      {
        res += compare ( d[ i ].cond, src ) * d[ i ].value;
      }
    }

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

  return ( 0 );
}

Measured memory_bytes: 0
using System;

namespace _0036
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = new string[8];
                string one = Console.ReadLine();
                if (one == null)
                {
                    break;
                }
                s[0] = one;
                for (int i = 1; i < 8; i++)
                {
                    s[i] = Console.ReadLine();
                }
                bool flag = true;
                for (int i = 0; i < 8 && flag; i++)
                {
                    for (int j = 0; j < 8 && flag; j++)
                    {
                        if (s[i][j] == '1')
                        {
                            if (i < 7 && j < 7 && s[i + 1][j] == '1' && s[i][j + 1] == '1' && s[i + 1][j + 1] == '1')
                            {
                                flag = false;
                                Console.WriteLine("A");
                            }
                            else if (i < 5 && s[i + 1][j] == '1' && s[i + 2][j] == '1' && s[i + 3][j] == '1')
                            {
                                flag = false;
                                Console.WriteLine("B");
                            }
                            else if (j < 5 && s[i][j + 1] == '1' && s[i][j + 2] == '1' && s[i][j + 3] == '1')
                            {
                                flag = false;
                                Console.WriteLine("C");
                            }
                            else if (i < 6 && j > 0 && s[i + 1][j] == '1' && s[i + 1][j - 1] == '1' && s[i + 2][j - 1] == '1')
                            {
                                flag = false;
                                Console.WriteLine("D");
                            }
                            else if (i < 7 && j < 6 && s[i][j + 1] == '1' && s[i + 1][j + 1] == '1' && s[i + 1][j + 2] == '1')
                            {
                                flag = false;
                                Console.WriteLine("E");
                            }
                            else if (i < 6 && j < 7 && s[i + 1][j] == '1' && s[i + 1][j + 1] == '1' && s[i + 2][j + 1] == '1')
                            {
                                flag = false;
                                Console.WriteLine("F");
                            }
                            else
                            {
                                flag = false;
                                Console.WriteLine("G");
                            }
                        }
                    }
                }
                Console.ReadLine();
            }
        }
    }
}

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    v a = ga(n);

    sort(all(a));

    v sum(n);
    sum[0] = a[0];
    for (ll i = 1; i < n; i++) {
        sum[i] = sum[i - 1] + a[i];
    }

    if (k >= n) {
        cout << 0 << endl;
        return;
    }

    cout << sum[n - k - 1] << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int n, m;

    cin >> n >> m;

    if(m % n == 0){
        cout << m/n << endl;
        return 0;
    }
    else{
        for(int i = m/n; i > 0; i--){
            if((m - i * (n-1)) % i == 0 ){
                cout << i << endl;
                return 0;
            }
        }
    }
    
    /*
    else if(n % 2 == 0){
        if(m % 2 == 0){
            cout << 2 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else if(n % 2 == 1){
        if(m % 2 == 0){
            cout << m/n << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else{
        cout << m%n << endl;
    }
    */

    return 0;
}

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

int main(void){
  int h, a, t = 0;
  scanf("%d %d", &h, &a);
  
  for(int i=0;;i++){
    h = h-a;
    t = t+1;
    if(h<=0){
      break;
    }
  }
  printf("%d", t);
  
  

  return 0;
}

  


Measured memory_bytes: 1692
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s =scanner.next();
        int answer = 0;
        int instance = 0;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)=='A'||s.charAt(i)=='C'||s.charAt(i)=='G'||s.charAt(i)=='T'){
                instance++;
                if (instance>answer){
                    answer = instance;
                }
            }else{
                instance = 0;
            }
        }
        System.out.println(answer);
    }

}

Measured memory_bytes: 21844
/*
Author: Srinjoy
Language: C++ 17

consider overflow
carefully of negative in case of any function(mod ceil etc)
think about prefix sum if possible 
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.fi >> v.se;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}




int main(){
	optimiza_io
	
	string s1,s2;
	cin>>s1>>s2;

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

	string s3;
	cin>>s3;

	if(s3==s1) a-=1;
	else b-=1;

	cout<<a<<" "<<b<<endl;
	
}

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

int main()
{
  int n;
  cin >> n;
  uint x = 0;
  for (auto i = 0; i < n; i++) {
    uint u;
    cin >> u;
    x |= u;
  }
  cout << (x & 1 ? "first" : "second") << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

const int MAX_N = 9;
int N, M;
vector<int> A[MAX_N];
bool visited [MAX_N];

int DFS(int cur, int depth)
{
    if(visited[cur])
        return 0;
    if(depth == N)
        return 1;

    visited[cur] = 1;

    int num_path = 0;
    for(size_t j = 0; j < A[cur].size(); ++j)
    {
        const int next = A[cur][j];
        if(visited[next]) continue;
        num_path += DFS(next, depth + 1);
    }

    visited[cur] = 0;
    return num_path;
}

int main(int, char *[])
{
    cin >> N >> M;
    for(int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }

    const int path = DFS(1, 1);
    cout << path << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define ll long long
#define MAX 200005  
#define mp make_pair
const int M=1e9+7;
const int mod=998244353;
typedef double ld;
bool visited[MAX];
ll qpow(ll x, ll k,ll m) {return k==0? 1: 1ll*qpow(1ll*x*x%m,k>>1,m)*(k&1?x:1)%m;}
ll modinv(ll a,ll m){ll g=__gcd(a,m);return (g==1)? qpow(a,m-2,m):-1;}

string lcs(string a,string b)
{
    int n=a.size(),m=b.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(a[i-1]==b[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i=n,j=m;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans+=a[i-1];
            i--,j--;
        }
        else 
        {
            if(dp[i][j-1]>dp[i-1][j])
                j--;
            else
                i--;
        }
    }
    reverse(ans.begin(),ans.end());
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
    string a,b;
    cin>>a>>b;
    //int n=s.length();
    cout<<lcs(a,b)<<endl;
    return 0;
}





Measured memory_bytes: 35456
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, M = MI()
    graph = [[] for i in range(N+1)]
    ans = 0

    for i in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    q = deque()
    q.append((1, set([1])))

    while len(q) != 0:
        edge, visited = q.popleft()
        nxt = graph[edge]

        if len(visited) == N:
            ans += 1

        for i, e in enumerate(nxt):
            if e not in visited:
                v = visited.copy()
                v.add(e)
                q.append((e, v))
            # else:
            #     print('stop', e, visited)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7888
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var max = 0;
        var ans = 0L;
        for (int i = 0; i < n; i++)
        {
            if (a[i] > max) max = a[i];
            else if (a[i] < max) ans += max - a[i];
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 46240
#include <iostream>
#include <vector>

using namespace std;



int main() {
	int V,E,r,s,t,din;
	vector<int> d,weight;
	vector<pair<int,int> > edge;

	cin >> V >> E >> r;
	for(int i=0;i<E;i++){
		cin >> s >> t >> din;
		edge.push_back(make_pair(s,t));
		weight.push_back(din);
	}

	for(int i=0;i<V;i++) {
		d.push_back(1000000000);
	}
	if(d.size()) d[r] = 0;
	if(!d.size()) d.push_back(0);

	for(int i=1;i<V;i++) {
		bool update = false;
		for(int j=0;j<E;j++) {
			int oldd = d[edge[j].second];
			d[edge[j].second] = min(d[edge[j].second],d[edge[j].first]+weight[j]);

			if(oldd != d[edge[j].second]) update = true;
		}
		if(!update) break;
	}
	for(int i=0;i<V;i++) {
		if(d[i] == 1000000000) {
			cout << "INF" << endl;
		} else {
		    cout << d[i] << endl;
		}
	}
}

Measured memory_bytes: 10700
#!/usr/bin/env python3
from fractions import gcd
N = input()
A = list(map(int, input().split(" ")))
def lcm(x, y):
    return (x * y) // gcd(x, y)
tmp = 1
for i in A:
    tmp = lcm(tmp, i)
print(sum([tmp // i for i in A]) % (10**9 + 7))

Measured memory_bytes: 264672
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n):N(n){
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        setPrimeSet();
    }

    vector<int> getFactor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //素因数の重複なしが欲しいなら、以下のコメントアウトを解除
        return res;
    }

    vector<int> getFactorSet(int i){
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }
};



int main(){
    int n;cin>>n;
    osa_k o(1000005);
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> s(1000005);
    int co=a[0];
    for(int i=0;i<n;i++){
        co=gcd(co,a[i]);
    }
    if(co!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        vector<int> tmp=o.getFactorSet(a[i]);
        for(int j=0;j<tmp.size();j++){
            if(s[tmp[j]]>0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            else{
                s[tmp[j]]+=1;
            }
        }
    }
    cout<<"pairwise coprime"<<endl;    

    return 0;
}

Measured memory_bytes: 15328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    for(int i=1; i<=n; i++){
        if(i%3==0 || i%10==3 || i%100/10==3 || i/100==3|| i%100==3|| i/1000==3|| i%1000==3|| i%1000/10==3|| i%1000/100==3){
            cout << " " << i;
        }
    }
    cout << endl;
}


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

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

int modexp(int a,int n,int mod){
    if(n == 0){
        return 1;
    }
    ll res = modexp(a*a%mod,n/2,mod);
    if(n&1){
        res=(res*a)%mod;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans = 0;
    if(p == 2 || p == 5){
        for(int i = 0; i<n; i++){
            if((s[i]- '0')%p == 0){
                ans+=(i+1);
            }
        }
        cout<<ans<<"\n";
    }
    else{
    ll cnt[p];
    memset(cnt,0,sizeof(cnt));
    cnt[0] = 1;
    int cur = 0;
    for(int i = 0; i<n; i++){
        cur*=10;
        cur+= (s[i] - '0');
        cur%=p;
        int val = modexp(10,n-i-1,p)*cur;
        val = val%p;
        cnt[val]++;
    }
    
    for(int i = 0; i<p; i++){
        ans += (cnt[i]*(cnt[i]-1))/2;
    }
    cout<<ans<<"\n";
    }
}

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

int gcd(int a, int b, int c) {
  int minimum = min(a, min(b, c));
  int ans = 0;
  for(int i = 1; i < minimum + 1; i++) {
    if(a % i == 0 && b % i == 0 && c % i == 0)
      ans = i;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N + 1; i++) {
    for(int j = 0; j < N + 1; j++) {
      for(int k = 0; k < N + 1; k++) {
        sum = sum + gcd(i, j, k);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>
int main()
{
    int m,n,a[10],i,k=0;
    scanf("%d %d",&m,&n);
    for(i=m;i<=n;i++)
    {
        a[0]=i/10000;
        a[1]=i%10000/1000;
        a[2]=i%10000%1000/100;
        a[3]=i%100/10;
        a[4]=i%10;
        if(a[0]==a[4]&&a[1]==a[3])
            k++;
    }
    printf("%d\n",k);

    return 0;
}


Measured memory_bytes: 760
import sys
input = sys.stdin.readline

# B - Box and Ball
N, M = map(int, input().split())

boxes = [1] * (N + 1)
boxes[0] = 0

ball_exists = set()
ball_exists.add(1)

for i in range(M):
  x, y = map(int, input().split())

  boxes[x] -= 1
  boxes[y] += 1
  
  if x in ball_exists:
    if boxes[x] == 0:
      ball_exists.remove(x)

      if len(ball_exists) == 1 and y in ball_exists:
        ball_exists.clear()

    ball_exists.add(y)

  #print(boxes)
  #print(ball_exists)

print(len(ball_exists))

Measured memory_bytes: 18064
#include<bits/stdc++.h>
using namespace std;
int64_t MAGIC = 998244353;

int64_t power_a(int64_t a, int64_t n){
  int64_t res = 1;
  while(n){
    if(n&1){
      res = (res* a) % MAGIC;
    }
    n = n >> 1;
    a = (a*a)%MAGIC;
  }
  if(a == 0 && n == 0){
    return 0;
  }else{
    return res;
  }
}
    
    
int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> d(n);
  int64_t maxd = 0;
  for(int i=0;i<n;i++){
    cin >> d.at(i);
    if(maxd < d.at(i)){
      maxd = d.at(i);
    }
  }
  bool validflag = true;
  if(d.at(0) != 0) validflag = false;
  
  vector<int> check(maxd+1);
  
  for(int i=0;i<n;i++){
    check.at(d.at(i))++;
  }
  
  int64_t result = 1;
  if(check.at(0) != 1){
    validflag = false;
  }else{
    for(int i=0;i<maxd;i++){
      result = (result * power_a(check.at(i),check.at(i+1))) % MAGIC;
    }
  }
  if(validflag){
    cout << result << endl;
  }else{
    cout << "0" << endl;
  }
}
    
    
    
  
  

Measured memory_bytes: 1408
n=int(input())
if n==1 or n==2 or n==3 or n==4 or n==5 or n==6 or n==7 or n==8 or n==9 or n==10 or n==12 or n==14 or n==15 or n==16 or n==18 or n==20 or n==21 or n==24 or n==25 or n==27 or n==28 or n==30 or n==32 or n==35 or n==36 or n==40 or n==42 or n==45 or n==48 or n==49 or n==54 or n==56 or n==63 or n==64 or n==72 or n==81:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX 100000
#define NMAX 1000000001

typedef struct {
  int num;
  char mark;
} Trump;

int partition(Trump *, int, int);
void quicksort(Trump *, int, int);
void merge(Trump *, int, int, int);
void mergeSort(Trump *, int, int);

int main() {
  int n, i, k;
  Trump card[MAX], cardb[MAX];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%*c%c%d", &card[i].mark, &card[i].num);
    cardb[i] = card[i];
  }

  

  mergeSort(cardb, 0, n);
  quicksort(card, 0, n-1);

  for (i = 0; i < n; i++) {
    if (card[i].mark != cardb[i].mark) {
      printf("Not stable\n");
      break;
    }
    else if (i == n-1) {
      printf("Stable\n");
    }
  }
  for (i = 0; i < n; i++) {
    printf("%c %d\n", card[i].mark, card[i].num);
  }


  return 0;
}

int partition(Trump *c, int p, int r) {
  int x, i, j;
  Trump temp;

  x = c[r].num;
  i = p-1;

  for (j = p; j < r; j++) {
    if (c[j].num <= x) {
      i++;
      temp = c[i];
      c[i] = c[j];
      c[j] = temp;
    }
  }
  temp = c[i+1];
  c[i+1] = c[r];
  c[r] = temp;
  
  return i+1;
}


void quicksort(Trump *c, int p, int r) {
  int q;
  if (p < r) {
    q = partition(c, p, r);
    quicksort(c, p, q-1);
    quicksort(c, q+1, r);
  }
}

void merge(Trump *data, int left, int mid, int right) {
  int n1, n2, i, j, k;
  Trump *l, *r;

  n1 = mid - left;
  n2 = right - mid;
  
  l = malloc((n1+1) * sizeof(Trump));
  r = malloc((n2+1) * sizeof(Trump));

  for (i = 0; i < n1; i++) {
    l[i] = data[left+i]; 
  }
  for (i = 0; i < n2; i++) {
    r[i] = data[mid+i];
  }
  l[n1].num = NMAX;
  r[n2].num = NMAX;
  
  i = 0;
  j = 0;

  for (k = left; k < right; k++) {
    if (l[i].num <= r[j].num) {
      data[k] = l[i];
      i++;
    }
    else {
      data[k] = r[j];
      j++;
    }
  }
}

void mergeSort(Trump *data, int left, int right) {
  int mid;
  if (left+1 < right) {
    mid = (left + right) / 2;
    mergeSort(data, left, mid);
    mergeSort(data, mid, right);
    merge(data, left, mid, right);
  }
}



Measured memory_bytes: 20560
raw1 = input().split()
H = int(raw1[0])
W = int(raw1[1])

c = [0 for x in range(26)]

for i in range(H):
    raw = input()
    for j in range(W):
        c[ord(raw[j]) - 97] += 1

for i in range(len(c)):
    c[i] = c[i] % 4


if c.count(3) > 0 :
    print('No')
elif W%2 == 1 and H%2 == 1 and c.count(1) == 1 and c.count(2) <= (H-1)/2 +(W-1)/2:
    print('Yes')
elif W%2 == 0 and H%2==0 and c.count(1)==0 and c.count(2) ==0:
    print('Yes')
elif W % 2 ==0 and  H % 2  == 1 and c.count(1) == 0 and c.count(2) <= W/2:
    print('Yes')
elif W % 2 ==1 and  H % 2  == 0 and c.count(1) == 0 and c.count(2) <= H/2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
double l;

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

	double tmp = l / 3;
	double ans = tmp * tmp * tmp;
	printf("%f",ans);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


int solve(int l, int r,vector<int>&h) {
    int ans=0;
    if (l == r) {
        ans = h[l];
        h[l] = 0;
        return ans;
    }
    
    //既に0があったら
    for(int i=l;i<=r;i++){
        if(h[i]==0){
            if(i==l) ans=solve(l+1,r,h);
            else if(i==r) ans=solve(l,r-1,h);
            else ans=solve(l,i-1,h)+solve(i+1,r,h);
            return ans;}
    }
    //0が無かったら
    int min=INF;
    for(int i=l;i<=r;i++){
        if(h[i]<min)
            min=h[i];
    }
    ans+=min;
    for(int i=l;i<=r;i++){
        h[i]-=min;
    }
    
    ans+=solve(l,r,h);
    return ans;
    
}

signed main(void) {
    int N;
    cin >> N;
    vector<int>h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    cout << solve(0, h.size() - 1, h) << endl;
    
    
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<LL> w(N),s(N),v(N);
	repp(i,0,N) cin >> w[i] >> s[i] >> v[i];
	vector<int> a(N);
	repp(i,0,N) a[i] = i;
	sort(a.begin(),a.end(),[&](const int &x, const int &y){return s[x]+w[x] < s[y]+w[y];});
	const int MC = 20010;
	vector<LL> dp(MC,0);
	repp(i,0,N){
		repm(j,s[a[i]],-1) dp[j+w[a[i]]] = max(dp[j+w[a[i]]],dp[j]+v[a[i]]);
	}
	LL ans = 0;
	repp(i,0,MC) ans = max(ans,dp[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long G=__gcd(c,d);
	long long L=c*d/G;
	long long e=b/c;
	long long f=(a-1)/c;
	long long x=e-f;
	long long g=b/d;
	long long h=(a-1)/d;
	long long y=g-h;
	long long i=b/L;
	long long j=(a-1)/L;
	long long z=i-j;
	long long X=x+y-z;
	long long ans=(b-a)-X+1;
	if(ans<0)
		cout<<0<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256