akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int GCD(int former, int latter){
    if(former % latter == 0)return latter;
    if(latter % former == 0)return former;
    return GCD(latter, former % latter);
}

int main(void){
    int N, Abuf, gcdAll;
    int numOne = 0;
    bool isPairwise = true;
    vector<int> A;
    vector<long long> primes;
    vector<bool> covered;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        if(Abuf == 1)numOne++;
        if(i==0){
            gcdAll = Abuf;
        }else{
            gcdAll = GCD(gcdAll, Abuf);
        }
    }
    if(gcdAll != 1){
        cout << "not coprime" << endl;
    }else{
        primes.push_back(2LL);
        for(long long i=3; i<1000; i+=2){
            bool isPrime = true;
            for(long long j: primes){
                if(i < j * j)break;
                if(i % j == 0){
                    isPrime = false;
                    break;
                }
            }
            if(isPrime)primes.push_back(i);
        }
        /*if(primes.size() < N - numOne){
            cout << "setwise coprime" << endl;
        }else{*/
            covered.assign(1000000, false);
            for(int i=0; i<N; i++){
                if(A[i] == 1)continue;
                for(long long p: primes){
                    bool flgMultiplier = false;
                    while(A[i] % p == 0){
                        if(covered[p]){
                            isPairwise = false;
                            break;
                        }
                        flgMultiplier = true;
                        A[i] /= p;
                    }
                    if(!isPairwise)break;
                    if(flgMultiplier){
                        covered[p] = true;
                    }
                    if(A[i]==1)break;
                }
                if(A[i] > 1){
                    if(covered[A[i]]){
                        isPairwise = false;
                    }else{
                        covered[A[i]] = true;
                    }
                }
                if(!isPairwise)break;
            }
            if(isPairwise){
                cout << "pairwise coprime" << endl;
            }else{
                cout << "setwise coprime" << endl;
            }
        /*}*/
    }
    return 0;
}

Measured memory_bytes: 7320
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,m,i,j;
		cin>>n>>m;
		string s[n];
		for(i=0;i<n;i++)
			cin>>s[i];
		int dp[n][m];
		if(s[0][0]=='.')
			dp[0][0]=0;
		else
			dp[0][0]=1;
		for(i=1;i<n;i++)
		{
			
			dp[i][0]=dp[i-1][0];
			if(s[i][0]=='#'&&s[i-1][0]!='#')
				dp[i][0]++;
		}
		for(i=1;i<m;i++)
		{
			
			dp[0][i]=dp[0][i-1];
			if(s[0][i]=='#'&&s[0][i-1]!='#')
				dp[0][i]++;
		}
		for(i=1;i<n;i++)
		{
			for(j=1;j<m;j++)
			{
				if(s[i][j]=='.')
				{
					dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
				}
				else
				{
					dp[i][j]=dp[i-1][j];
					if(s[i-1][j]!='#')
						dp[i][j]=dp[i-1][j]+1;
					if(s[i][j-1]!='#')
					{
						dp[i][j]=min(dp[i][j-1]+1,dp[i][j]);
					}
					else
						dp[i][j]=min(dp[i][j-1],dp[i][j]);
				}
			}
		}
		cout<<dp[n-1][m-1];



	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

int main(){
    ll X;
    cin >> X;
    ll out = 100;
    for (int i = 1;; i++){
      out += out /100;
      if(out>=X){
          cout << i << endl;
          break;
      }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int inp;
    cin >> inp;
    string inp_str = to_string(inp);

    int sum = 0;
    for(auto itr = inp_str.begin(); itr != inp_str.end(); itr++){
        sum += *itr - '0';
    }

    if(inp % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

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

    vector<int> backet(26, 0);
    for(int i = 0; i < s.length(); i++) backet[s[i]-'a']++;
    string s1 = "";
    for(int i = 0; i < 26; i++){
        while(backet[i]){
            s1 += (char)(i+'a');
            backet[i]--;
        }
    }

    for(int i = 0; i < t.length(); i++) backet[t[i]-'a']++;
    string t1 = "";
    for(int i = 25; i >= 0; i--){
        while(backet[i]){
            t1 += (char)(i+'a');
            backet[i]--;
        }
    }

    if(s1 < t1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,w;
cin>>n>>w;
int a[n],b[n];
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
long long dp[w+1]={0};
for(int i=0;i<n;i++)
{
for(int j=w-a[i];j>=0;j--)
dp[j+a[i]]=max(dp[j]+b[i],dp[j+a[i]]);
}
cout<<dp[w]<<endl;
return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  string s;
  int c=0,n;
  cin>>n;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='R') c++;
  }
  if(n-c<c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;



}



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

class program
{
  static void Main(string[] args)
  {
    char[] input = Console.ReadLine().ToArray();
    string output = "";
    for (int i = 0; i < input.Length; i ++)
    {
      output += input[i];
      i++;
    }
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 42676
#include<stdio.h>
#include<string.h>
int main(void)
{
	int N;
	char a[20] = "AC";
	char b[20] = "WA";
	char c[20] = "TLE";
	char d[20] = "RE";
	int i;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	char S[100];
	
	scanf("%d",&N);
	
	for( i = 0 ; i < N;i++)
	{
		scanf("%s",S);
		
		if(strcmp(S,a) == 0)
		{
			ac++;
		}
		else if(strcmp(S,b) == 0)
		{
			wa++;
		}
		else if(strcmp(S,c) == 0)
		{
			tle++;
		}
		else if(strcmp(S,d) == 0)
		{
			re++;
		}
	}
	
	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
    return 0;
}

Measured memory_bytes: 1708
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    vector<int> leftGCD(N+1),rightGCD (N+1);
    int LEFTgcd = 0;
    int RIGHTgcd = 0;
    leftGCD.at(0) = 0;
    rightGCD.at(N) = 0;
    //左から1個ずつ試すが、左からと右からの累積gcdをとる
    //左からLEFTgcdを増やしていく
    for(int i = 1;i<N;i++){
        LEFTgcd = gcd(LEFTgcd,retu.at(i-1));
        leftGCD.at(i) = LEFTgcd;
    }
    //右からRIGHTgcdを増やしていく
    for(int i = N-1;i>=0;i--){
        RIGHTgcd = gcd(RIGHTgcd,retu.at(i));
        rightGCD.at(i) = RIGHTgcd;
    }
    int ans = 1;
    //leftGCD.at(i)とrightGCD.at(i+2)のgcdの最大値が答え
    /*for(int A : leftGCD) cout << A << " ";
    cout << endl;
    for(int B : rightGCD) cout << B << " ";
    cout << endl;*/
    for(int i = 0;i<N;i++){
        ans = max(ans,gcd(leftGCD.at(i),rightGCD.at(i+1)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4468
N = int(input())
A = list(map(int, input().split()))

asum = {}
for a in A:
	if a not in asum:
		asum[a] = 1
	else:
		asum[a] += 1

#print(asum)

kouho = 0
for a in sorted(asum)[::-1]:
	if 4 <= asum[a]:
		if kouho:
			print(kouho * a)
		else:
			print(a * a)
		break
	elif 2 <= asum[a]:
		if kouho:
			print(kouho * a)
			break
		else:
			kouho = a
else:
	print(0)


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  string lib[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int t;
  cin >> t;
  for(;t--;){
    string input;
    cin >> input;
    char last='0';
    int ren=0;
    REP(i,SZ(input)){
      if(input[i]==last) ++ren;
      else{
	if(last-'0')
	  cout << lib[last-'0'][ren%SZ(lib[last-'0'])];
	ren=0;
      }
      last=input[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
 
int A[100000],od[100000];
char C[100000];
 
int Partition(int A[],char C[],int od[],int p,int r){
  int tp1,tp2,tpM,tpm,tpC,tpc;
  int i,j,x,stability,n;
   
  x = A[r];
  i = p-1;
  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i = i+1; 
      tp1 = A[i];
      tpM = C[i];
      tpC = od[i];
       
      A[i] = A[j];
      C[i] = C[j];
      od[i] = od[j];
      
      A[j] = tp1;
      C[j] = tpM;
      od[j] = tpC;
    }
  }
  tp2 = A[i+1];
  tpm = C[i+1];
  tpc = od[i+1];
   
  A[i+1] = A[r];
  C[i+1] = C[r];
  od[i+1] = od[r];
   
  A[r] = tp2;
  C[r] = tpm;
  od[r] = tpc;
   
  return i+1;
}
 
void Quicksort(int A[],char C[],int od[],int p,int r){
  int q;
   
  if(p < r){
    q = Partition(A,C,od,p,r);
    Quicksort(A,C,od,p,q-1);
    Quicksort(A,C,od,q+1,r);
  }
}
 
int main(){
  int n,i,stability=0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf(" %c%d",&C[i],&A[i]);
  }  
  for(i = 0 ; i < n ; i++){
    od[i] = i;
  }
  Quicksort(A,C,od,0,n-1);
  for(i = 0 ; i < n-1 ; i++){
    if(A[i] == A[i+1]){
      if(od[i] > od[i+1]){
        stability = 1;
        break;
      }
    }  
  }
  if(stability == 1){
    printf("Not stable\n");
  }
  else printf("Stable\n");
   
  for(i = 0 ; i < n ; i++){
    printf("%c %d\n",C[i],A[i]);
  }
   
  return 0;
}

Measured memory_bytes: 1484
#include <cstdio>

int search(int m, int *A, int n){
    int tmp1, tmp2, ret;
    if(n==0)ret = 0;
    else if(m<A[0])ret = search(m, A+1, n-1);
    else if(m==A[0])ret = 1;
    else if(m>A[0]){
        tmp1 = search(m-A[0], A+1, n-1);
        tmp2 = search(m, A+1, n-1);
        ret = tmp1 + tmp2;
    }
    return ret;
}

int main(){
    int i, n, q, m;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)scanf("%d",A+i);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&m);
        if(search(m, A, n))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2580
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n,m,ans=1,inf=1000000007;
	cin>>n>>m;
	if(m>n+1||n>m+1)ans=0;
	else if(m!=n)ans=1;
	else ans=2;
	rep(i,n){
	    ans*=n-i;
	    ans%=inf;
	}
	rep(i,m){
	    ans*=m-i;
	    ans%=inf;
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

map<char,int> m;
int main() {
    int n;cin>>n;
    for (int i = 0; i < n; i++) {
        string s;cin>>s;
        m[s[0]]++;
    }
    long long res = m['M'] * 1ll  * m['A'] * m['R'] +
                    m['M'] * 1ll  * m['A'] * m['C'] +
                    m['M'] * 1ll  * m['A'] * m['H'] +

                    m['M'] * 1ll  * m['R'] * m['C'] +
                    m['M'] * 1ll  * m['R'] * m['H'] +

                    m['M'] * 1ll  * m['C'] * m['H'] +

                    m['A'] * 1ll  * m['R'] * m['C'] +
                    m['A'] * 1ll  * m['R'] * m['H'] +

                    m['A'] * 1ll  * m['C'] * m['H'] +

                    m['R'] * 1ll  * m['C'] * m['H'];

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
#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,m;
    cin >> n >> m;
    vector<P>ans;
    if(n%2) {
        for(int l = 1,r = n-1;l < r;l++,r--) {
            ans.push_back({r,l});
        }
    } else {
        bool flag = false;
        for(int l  = 1, r = n-1; l < r;l++,r--) {
            if(!flag && r-l <= n/2) {
                r--;
                flag = true;
            }
            ans.push_back({r,l});
        }
    }
    rep(i,m) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}

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

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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  auto calc_satisfaction_level = [&s,&c](int d,int i,auto last){
    int64_t res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  //-----------------------------------------------------

  int k = 500;
  vector<vector<int>> last(k,vector<int>(26));
  vector<vector<int>> ans(k,vector<int>(d));
  vector<int64_t> top_k_val(k);

  auto test_all_get_max = [&](int di,auto last){
    // 日付を引数にして全てのコンテストタイプを試してmaxscoreになるタイプを返す
    // 上位k個を返す
    vector<pair<int,int>> valtype_max(26);
    for(int type=0;type<26;++type){
      valtype_max[type] = {calc_satisfaction_level(di,type,last),type};
    }
    sort(begin(valtype_max),end(valtype_max),greater<>());
    valtype_max.erase(begin(valtype_max)+k,end(valtype_max));
    assert(size(valtype_max)==k);
    return valtype_max;
  };

  rep(di,d){
    vector<tuple<int,int,int>> next_top_k;
    next_top_k.reserve(k*26);
    rep(ki,k){
      auto tmp = test_all_get_max(di,last[ki]);
      for(int i=0;i<26;++i)next_top_k.emplace_back(tmp[i].first+top_k_val[ki],tmp[i].second,ki);
    }
    sort(begin(next_top_k),end(next_top_k),greater<>());
    next_top_k.erase(begin(next_top_k)+k,end(next_top_k));
    vector<vector<int>> nxt_last(k,vector<int>(26));
    vector<vector<int>> nxt_ans(k,vector<int>(d));
    vector<int64_t> nxt_top_k_val(k);
    rep(i,k){
      auto [val,type,prv_ki] = next_top_k[i];
      nxt_last[i] = last[prv_ki];
      nxt_last[i][type] = di+1;
      nxt_ans[i] = ans[prv_ki];
      nxt_ans[i][di] = type;
      nxt_top_k_val[i] = val;
    }
    last = nxt_last;
    ans = nxt_ans;
    top_k_val = nxt_top_k_val;
  }

  //-----------------------------------------------------

  for(int i=0;i<d;++i)cout<<ans[0][i]+1<<endl;

}

Measured memory_bytes: 5184
A, B, C = map(int, input().split())

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
while True:
	if any([A % 2, B % 2, C % 2]):
		break
	A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
	count += 1
print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d %d",&a,&b);
	c = a*b;
	if (c == 2 || c == 4 || c == 6) {
		printf("No");
	} else {
		printf("Yes");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

int exp_mod(long long a, long long b, int m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (int)res;
}

int fact_mod(int n, int m) {
	long long res = 1;
	for (int i=n; i>0; --i)
		res = (res * i)%m;
	return (int)res;
}

int comb_mod(int n, int r) {
	long long res = 1;
	for (int i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

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

  long n, m;

  cin >> n >> m;

  cout << ((n*3)+m)/2 << endl;
  
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int K;
	cin >> K;
	ll seven = 7;
	ll ten = 1;
	ll num = seven * ten;
	ll count = 1;
	while(count <= 10000000){
		if(num % K == 0){
			cout << count << endl;
			return 0;
		}
		ten *= 10;
		ten %= K;
		num += seven * ten;
		num %= K;
		count ++;
	}
	cout << -1 << endl;
	return 0;
}


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

int lenStr, lenT;
string str, t;

bool ans;

int main()
{
    cin >> str >> t;
    lenStr = str.length();
    lenT = t.length();
    str += str;

    ans = false;
    for(int i = 0; i < lenStr && !ans; i++)
    {
        bool ok = true;
        for(int j = 0; j < lenT; j++)
            if(str[i + j] != t[j])
            {
                ok = false;
                break;
            }

        ans = ok;
    }

    if(!ans || lenStr != lenT)
        cout << "No" << '\n';
    else
        cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb puhs_back
using namespace std;
typedef pair< ll, ll> pll;


ll n;
ll a[100005];
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
        }
        a[n+1] = 1e16;
        for(ll i=1;i<=n;i++) {
                if(a[i] >= a[i-1] && a[i] <= a[i+1]) {
                        if(a[i]-1 >= a[i-1]){
                                a[i]--;
                        }
                }else{
                        a[i]--;
                        if(a[i] < a[i-1] || a[i] > a[i+1]){
                                cout << "No\n"; return 0;
                        }
                }
        }
        cout << "Yes\n";
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>  
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("xxx.in","r",stdin);freopen("xxx.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const double inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
const int maxn = 2e5+5;

char a[maxn];
int main()
{
	scanf("%s",a + 1);
	int n = strlen(a + 1);
	for (int  i = 1; i <= n; i ++ )
	{
		if(a[i] == '?')
			a[i] = 'D';
	}
	printf("%s\n",a + 1);
}


Measured memory_bytes: 3352
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]

tall=[1]*n

for i in range(m):
  if h[ab[i][0]-1]<h[ab[i][1]-1]:
    tall[ab[i][0]-1]=0
  elif h[ab[i][0]-1]>h[ab[i][1]-1]:
    tall[ab[i][1]-1]=0
  else:
    tall[ab[i][1]-1]=0
    tall[ab[i][0]-1]=0


print(sum(tall))

Measured memory_bytes: 31892
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
    int a,b,c;
    int arr[3];
    while(cin>>a>>b>>c) {
        arr[0] = a;
        arr[1] = b;
        arr[2] = c;
        sort(arr,arr+3);
        if(arr[0] == 5 && arr[1] == 5 && arr[2] == 7) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 256
i;j;M;m;main(N,q){
int c[9]={};
scanf("%d",&N);
for(;i<N;i++){
	scanf("%d",&q);
  	q/=400;
  	q<8?c[q]=1:M++;
}
for(;j<8;j++){
	M+=c[j];   
	m+=c[j];
}
m?:m++;
printf("%d %d",m,M);
}

Measured memory_bytes: 1708
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

A, B, C, D = map(int,input().split())
print(B-B//C-B//D+B//lcm(C,D)-((A-1)-(A-1)//C-(A-1)//D+(A-1)//lcm(C,D)))

Measured memory_bytes: 3064
let () =
    let main () =
        let m = 1_000_000_000 + 7 in
        let (+@) a b = (a + b) mod m in
        let s = read_line () in
        let a = Array.make 13 0 in
        let l = String.length s in
        let rec loop i a =
            if i = l then a else
                let b = Array.make 13 0 in
                let () =
                    if s.[i] = '?' then (
                        for j = 0 to 12 do
                            for k = 0 to 9 do
                                b.((j * 10 + k) mod 13) <- b.((j * 10 + k) mod 13) +@ a.(j)
                            done
                        done
                    ) else (
                        let k = int_of_char s.[i] - int_of_char '0' in
                        for j = 0 to 12 do
                            b.((j * 10 + k) mod 13) <- b.((j * 10 + k) mod 13) +@ a.(j)
                        done
                    )
                in
                loop (i + 1) b
        in
        let a = loop 0 (Array.init 13 (fun i -> if i = 0 then 1 else 0)) in
        Printf.printf "%d\n" a.(5)
    in
    main ()

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <numeric>
#include <iterator>
using namespace std;

int solve(int n, int k, int s, vector<int> v) {
  if ((int)v.size() == k) {
    /*
    for (auto x : v) {
      cerr << x << " ";
    }
    cerr << endl;
    */
    int sum = accumulate(v.begin(), v.end(), 0);
    if (sum == s) {
      return 1;
    } else {
      return 0;
    }
  }
  int start = (v.empty() ? 0 : v[v.size()-1]);
  int ans = 0;
  for (auto i = start+1; i <= n; i++) {
    vector<int> nv;
    copy(v.begin(), v.end(), back_inserter(nv));
    nv.push_back(i);
    ans += solve(n, k, s, nv);
  }
  return ans;
}

int main() {
  int n, k, s;
  while (cin >> n >> k >> s && n) {
    vector<int> v;
    cout << solve(n, k, s, v) << endl;
  }
}

Measured memory_bytes: 3012
use std::f64::consts::PI;

fn main() {
  let stdin = std::io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();

  let mut ite = buf.trim().split_whitespace()
    .map(|x| x.parse::<f64>().unwrap());

  let a = ite.next().unwrap();
  let b = ite.next().unwrap();
  let c = ite.next().unwrap();

  let rad = c.to_radians();

  println!("{}", a * b * rad.sin() * 0.5);
  println!("{}", (a.powi(2) + b.powi(2) - 2. * a * b * rad.cos()).sqrt() + a + b);
  println!("{}", b * rad.sin());
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    ll K, X, Y; cin >> K >> X >> Y;
    if (K % 2 == 0 && (abs(X) + abs(Y)) % 2 == 1) {
        cout << -1 << endl; return 0;
    }
 
    ll curX = 0, curY = 0;
 
    ll ans = (abs(X) + abs(Y) +K-1)/K;
    if (ans == 1 && (abs(X)+abs(Y)) != K) ans++;
    while ((ans*K-abs(X)-abs(Y))%2 != 0) ans++;
 
    ll waste = ans*K; waste -= (abs(X)+abs(Y)); waste /= 2;
    cout << ans << endl;
    bool loX = abs(X) < abs(Y);
    while (waste > 0) {
        if (loX && X >= 0) {
            curX -= min(waste, K);
        } else if (loX) {
            curX += min(waste, K);
        } else if (Y >= 0) {
            curY -= min(waste, K);
        } else {
            curY += min(waste, K);
        }
        ll leftover = K - min(waste, K);
        //cout << leftover << endl;
        if (loX) {
            //adjust Y
            if (curY < Y) {
                curY += leftover;
            } else {
                curY -= leftover;
            }
        } else {
            if (curX < X) {
                curX += leftover;
            } else curX -= leftover;
        }
 
        waste -= min(waste, K);
        cout << curX << " " << curY << endl;
        loX = abs(X-curX) < abs(Y-curY);
    }
 
    while (curX != X || curY != Y) {
        ll rem = K;
        if (curX != X) {
            ll todo = min(K, abs(X-curX));
            if (curX < X) {
                curX += todo;
            } else {
                curX -= todo;
            }
            rem -= todo;
        }
        if (curY != Y) {
            ll todo = min(rem, abs(Y-curY));
            if (curY < Y) {
                curY += todo;
            } else curY -= todo;
        }
 
        cout << curX << " " << curY << endl;
    }
 
 
 
    return 0;
}

Measured memory_bytes: 3696
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ0258().doIt();
	}
	
	class AOJ0258{
		int n;
		int[] input;
		
		void solve(){
			int result = -1;
			for(int i=0;i<=n;i++){
				ArrayList<Integer> list = new ArrayList<Integer>();
				for(int s=0;s<=n;s++)if(s!=i){
					list.add(input[s]);
				}
				int crr = list.get(1)-list.get(0);
				boolean sw = true;
				for(int s=0;s<list.size()-1;s++)if(list.get(s+1)-list.get(s)!=crr)sw=false;
				if(sw){
					result = input[i];break;
				}
			}
			System.out.println(result);
		}
		
		void doIt(){
			while(in.hasNext()){
				n = in.nextInt();
				if(n==0)break;
				input = new int[n+1];
				for(int i=0;i<=n;i++)input[i] = in.nextInt();
				solve();
			}
		}
	}
	
}

Measured memory_bytes: 54884
n = int(input())
a,b = map(int, input().split())
p = list(map(int, input().split()))

cnt=[0,0,0]
for poi in p:
  if poi <= a:
  	cnt[0]+=1
  elif poi <=b:
    cnt[1]+=1
  else:
    cnt[2]+=1
print(min(cnt))

Measured memory_bytes: 61900
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  set<int> a;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    a.insert(s);
  }
 
  int ans=0;
  auto itr=a.begin();
 while(itr!=a.end()){
     ans++;
   itr++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;


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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int[] count=new int[26];
		char ch='a';
		for(;(str=br.readLine())!=null;){
			str=str.toLowerCase();
			for(int i=0;i<str.length();i++){
				if(Character.isLetter(str.charAt(i)))
					count[Character.toLowerCase(str.charAt(i))-'a']++;
				
			}
		}
		for(int i=0;i<26;i++){
			System.out.println(ch++ +" : "+count[i]);
		}
	
	
	}}

Measured memory_bytes: 17036
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  map<char, i64> m;
  for (i64 i = 0; i < 4; i++)
    m[s[i]]++;
  bool ans = true;
  for (pair<char, i64> i : m)
    if (i.second != 2)
      ans = false;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
vl bitList(ll n, ll k, ll f) {
	vl bitList(k);
	for (ll i = 0; i < k; i++) {
		bitList[i] = f % n;
		f /= n;
	}
	return bitList;
}
int main() {
	cin >> N >> K;
	vl A(N), B(N);
	vll P(N, vl(30));
	for (i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		P[i] = bitList(2, 30, A[i]);
		reverse(P[i].begin(), P[i].end());
	}
	vl L = bitList(2, 30, K);
	reverse(L.begin(), L.end());
	// 前から何桁目でsmaller確定するかで回す
	for (k = 0; k < 30; k++) {
		if (k!=29 && L[k] == 0) continue;
		vl F(N,1);
		for (i = 0; i < k; i++) {
			if (L[i] == 0) {
				for (j = 0; j < N; j++) {
					if (P[j][i] == 1) F[j] = 0;
				}
			}
		}
		if (!(k == 29 && L[i]==1)) {
			for (j = 0; j < N; j++) {
				if (P[j][k] == 1) F[j] = 0;
			}
		}
		ll pre = 0;
		for (i = 0; i < N; i++) {
			if (F[i]) pre += B[i];
		}
		//debug(pre);
		ans = max(ans, pre);
	}
	cout << ans;
}

Measured memory_bytes: 33072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  ll x = min(n,b-1);
  ll fl1 = a*x/b;
  ll fl2 = x/b;
  ll ans = fl1 - a*fl2;
  cout << ans << endl;
  return 0;
}


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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,m;
        cin>>n>>m;
        vector<string>s(n);
        for(int i=0;i<n;i++)
            cin>>s[i];
        vector<vector<int>>a(n,vector<int>(m));
        a[0][0]=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(s[i][j]=='#')
                    continue;
                if(i==0 && j==0)
                    continue;
                if(i==0)
                    a[i][j]=a[i][j-1];
                else if(j==0)
                    a[i][j]=a[i-1][j];
                else
                    a[i][j]=(a[i][j]%MOD + a[i-1][j]%MOD + a[i][j-1]%MOD)%MOD;
            }
        }
        cout<<a[n-1][m-1];
        return 0;
    }


Measured memory_bytes: 5248
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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; }
#pragma endregion

int main() {
  IN(int, A);
  IN(int, B);
  IN(int, C);
  IN(int, X);
  IN(int, Y);
  int min = X;
  chmin(min, Y);
  int sum = 0;
  if (C * 2 < A + B) {
    sum += C * 2 * min;
  } else {
    sum += (A + B) * min;
  }
  if (min == X) {
    if (B < C * 2) sum += B * (Y - min);
    else sum += C * 2 * (Y - min);
  } else {
    if (A < C * 2) sum += A * (X - min);
    else sum += C * 2 * (X - min);
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
#define int long long

const int MAX_N = 100010;




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	map<int, bool>mp;
	rep(i, n) {
		int a; cin >> a;
		if (mp[a])mp[a] = false;
		else mp[a] = true;
	}
	int ans = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main() {
     int N, K;
     cin >> N >> K;
     for(int n=0; n<N; n++) {
        int A;
        cin >> A;
     }
     N-=K;
     if(N%(K-1)==0) {
        cout << N/(K-1)+1 << endl;
     } else {
        cout << N/(K-1)+2 << endl;
     }


    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if (a < b) {
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int h, w;
char s[50][50];
int check[50][50];

int check_map(int i, int j){
    int nx[4] = {1, -1, 0, 0};
    int ny[4] = {0, 0, 1, -1};
    int flag = 0;

    for(int k = 0; k < 4; k++){
        int dx = i + ny[k];
        int dy = j + nx[k];

        if(dx >= 0 && dx < h && dy >= 0 && dy < w && s[dx][dy] == '#'){
            check[dx][dy] = 1;
            check[i][j] = 1;
            flag = 1;
            break;
        }
    }

    return flag;
}

int main(){
    cin >> h >> w;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
            check[i][j] = 0;
        }
    }


    int flag = 0;
    int ans = 0;
    for(int i = 0; i < h; i++){
        flag = 0;
        for(int j = 0; j < w; j++){
            flag = 0;
            if(s[i][j] == '#' && check[i][j] == 0){
                flag = check_map(i, j);
                if(flag == 0){
                    ans = -1;
                    break;
                }
            }
        }
        if(ans == -1){
            break;
        }
    }

    if(ans == -1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif

let INPUT = stdin

var buffer: UnsafeMutablePointer<CChar>?
var bufferCapacity: Int32 = 0

func getsToBuffer(size: Int32) -> UnsafeMutablePointer<CChar> {
    if bufferCapacity < size {
        buffer?.deallocate()
        buffer = UnsafeMutablePointer.allocate(capacity: Int(size))
        bufferCapacity = size
    }
    return fgets(buffer!, size, INPUT)
}
func getIntFromBuffer(_ ptr: inout UnsafeMutablePointer<CChar>) -> Int {
    var minus = false
    var x: Int?
    while true {
        switch ptr.pointee {
        case 0x2D:
            assert(!minus && x == nil)
            minus = true
        case let d where (0x30...0x39).contains(d):
            x = (x ?? 0)*10 + Int(d)-0x30
        default:
            if x != nil { return minus ? -x! : x! }
        }
        ptr += 1
    }
}
func getInt() -> Int {
    var xPtr = getsToBuffer(size: 24)
    return getIntFromBuffer(&xPtr)
}
func getIntPair() -> (Int, Int) {
    var xPtr = getsToBuffer(size: 2*24)
    let x1 = getIntFromBuffer(&xPtr)
    let x2 = getIntFromBuffer(&xPtr)
    return (x1, x2)
}
func getIntTriplet() -> (Int, Int, Int) {
    var xPtr = getsToBuffer(size: 2*24)
    let x1 = getIntFromBuffer(&xPtr)
    let x2 = getIntFromBuffer(&xPtr)
    let x3 = getIntFromBuffer(&xPtr)
    return (x1, x2, x3)
}
func getInts(count: Int) -> [Int] {
    var xPtr = getsToBuffer(size: Int32(count) * 24)
    var a = [Int]()
    a.reserveCapacity(count)
    for _ in 0..<count { a.append(getIntFromBuffer(&xPtr)) }
    return a
}

//=============================================================================

struct Table {
    private var data: [Int]
    private let d1, d2, d3: Int
    private let s1, s2: Int
    init(_ d1: Int, _ d2: Int, _ d3: Int) {
        self.d1 = d1
        self.d2 = d2
        self.d3 = d3
        s1 = d2 * d3
        s2 = d3
        data = [Int](repeating: 0, count: d1*d2*d3)
    }
    subscript(i: Int, j: Int, k: Int) -> Int {
        get { data[i*s1 + j*s2 + k] }
        set { data[i*s1 + j*s2 + k] = newValue }
    }
}

let (R, C, K) = getIntTriplet()
var items = Table(R+1, C+1, 1)
for _ in 0..<K {
    let (r, c, v) = getIntTriplet()
    items[r, c, 0] = v
}

var dp = Table(R+1, C+1, 4)

for i in 1...R {
    for j in 1...C {
        let item = items[i, j, 0]
        let maxUp = max(dp[i-1, j, 0], dp[i-1, j, 1], dp[i-1, j, 2], dp[i-1, j, 3])
        dp[i, j, 0] = maxUp
        dp[i, j, 1] = maxUp + item
        for k in 0...3 { dp[i, j, k] = max(dp[i, j, k], dp[i, j-1, k]) }
        for k in 1...3 { dp[i, j, k] = max(dp[i, j, k], dp[i, j-1, k-1] + item)}
    }
}

print(max(dp[R, C, 0], dp[R, C, 1], dp[R, C, 2], dp[R, C, 3]))


Measured memory_bytes: 359132
//use pair to make pair
#include "iostream"
#include "set"
#include "algorithm"
using namespace std;
char ch[105];
int main()
{
    pair<pair<string,int>,int> p[110];
    int t;
    cin>>t;
    int l;
    for(int i=0;i<t;i++)
    {
        cin>>ch>>l;
        string temp=ch;
        p[i]=make_pair(make_pair(ch,-l),i);
        
    }
    
    sort(p,p+t);
    
    for(int i=0;i<t;i++)
    {
        cout<<p[i].second+1<<endl;
    }
    
    
}


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

int main() {
 int X[2], Y[2];
 for (int i = 1; i < 2+1; i++) {
   cin >> X[i] >> Y[i];
 }
 int x = X[2] - X[1], y = Y[2] - Y[1];
 cout << X[2] - y << " " << Y[2] + x << " " <<  X[1] - y << " " << Y[1] + x;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<int> wc(N);
    vector<bool> isC(N);
    for(int i = 0; i < N; i++){
        wc[i] = 0;
        isC[i] = false;
    }
    for(int i = 0; i < M; i++){
        ll p; string s;
        cin >> p >> s;
        p--;
        if(s == "WA"){
            if(!isC[p]){
                wc[p]++;
            }
        }else{
            isC[p] = true;
        }
    }
    ll sumW = 0;
    ll sumA = 0;
    for(int i = 0; i < N; i++){
        if(isC[i]){
            sumA++;
            sumW+= wc[i];
        }
    }
    cout << sumA << " " << sumW << endl;
}

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

// stringはscanfで読み取れない？（scanfがC由来だから？）

int A, B, ans;

int main() {
  
  scanf("%d%d", &A, &B);
  ans = max(0, A - 2 * B);
  printf("%d\n", ans);

  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, x;
  cin >> n >> x;

  ll b_num[55], p_num[55];
  fill(b_num, b_num + 55, 0LL);
  fill(p_num, p_num + 55, 0LL);
  b_num[0] = 1;
  p_num[0] = 1;

  for(int i = 1; i <= 50; ++i)
  {
    b_num[i] = b_num[i - 1] * 2 + 3;
    p_num[i] = p_num[i - 1] * 2 + 1;
  }

  ll ans = 0;
  auto lv_mid = [&](ll lv){ return (b_num[lv] + 1) / 2LL; };
  ll pos = 0;
  for(int lv = n; lv >= 0; --lv)
  {
    ll mid = lv_mid(lv);
    // cout << "Lv" << lv << " / pos : " << pos << " + " << mid << " = " << pos + mid << endl;

    // 半分より左
    if (x < mid + pos)
    {
      pos++;
      continue;
    }

    if (lv > 0) ans += p_num[lv - 1] + 1;
    else ans++;

    // ちょうど半分
    if (x == mid + pos) break;

    // 半分より右
    pos += mid;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    vector<ll> H(100001);
    cin >> n;
    int i;
    rep(i,n){
        cin >> H.at(i);
    }
    ll max = 0,count = 0;
    rep(i,n){
        if(i==n)break;
        if(H.at(i)>=H.at(i+1)){
            count++;
            //cout <<"count" << count<< endl;
        }
        else {
            if(count > max)max = count;
            count = 0;

            //cout <<"max" << i  << endl;
        }
    }
    if(count > max)max = --count;
    cout << max;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int a, b, c, date = 0;
	int week;
	int ans;
	scanf("%d %d %d",&a, &b, &c);

	week = a * 7 + b;

	date += c / week;
	ans = date * 7;
	 
	c -= week * date;

	if (c < a * 7) {
		if (c%a == 0) {
			ans += c / a;
		}
		else {
			ans += c / a + 1;
		}
	}
	else {
		ans += 7;
	}

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


Measured memory_bytes: 2148