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

string shuffle(string str,int num){
	string newStr(str.length(),'a');
	for(int i = 0; i < str.length() ; i++){
		newStr[i] = str[ ( i + num) % str.length() ];
	}
	return newStr;
}

int main()
{
	string str;
	int shuffleCount;
	cin >> str;
	while(str !="-"){
		cin >> shuffleCount;
		for(int i = 0; i < shuffleCount; i++){
			int repNum;
			cin >> repNum;
			str = shuffle(str,repNum);
		}
		cout<< str <<endl;
		cin >> str;
	}
	return 0;
}

Measured memory_bytes: 3128
def time(inp):
  h1,m1,s1,h2,m2,s2 = inp
  s = s2 - s1
  if s < 0:
    s += 60
    m2 -= 1
  m = m2 - m1
  if m < 0:
    m += 60
    h2 -= 1
  h = h2 - h1
  print(h,m,s)
for i in range(3):
  time(tuple(map(int,input().split())))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const int mod=998244353;
int n,d[max_n];
inline ll Pow(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%mod;
        y>>=1;x=x*x%mod;
    }
    return res;
}
int main(){
    scanf("%d",&n);
    int f=-1;
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        d[x]++;
        if(i==1)f=x;
    }
    ll ans=1;
    int cnt=0;
    if(d[0]!=1||f!=0)ans=0;
    cnt++;
    for(int i=1;i<=n;i++){
        if(d[i]==0){
            if(cnt==n)break;
            else ans=0;
        }
        else{
            ans=ans*Pow(d[i-1],d[i])%mod;
            cnt+=d[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

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

int S(string N)
{
  int sum = 0;

  for (int i = 0; i < N.length(); i++)
  {
    char num = N[i];
    // cout << typeid(num).name() << endl;
    sum += ctoi(num);
  }

  return sum;
}

int main()
{

  string N;

  cin >> N;

  int result = S(N);

  if (stoi(N) % result == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n;
    cin>>n;
    
    string ans;
    while(n!=0&&n!=1){
        if(n<0&&n%2==-1){
            n/=(-2);
            n++;
            ans+='1';
        }
        else{
            ans+=(char)('0'+n%2);
            n/=-2;
        }
    }
    ans+='0'+n;
    while(sz(ans)>1 && ans[sz(ans)-1]=='0') ans.pop_back();
    reverse(all(ans));
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(){
	int a, b; cin >> a >> b;
	if(a <= b) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

Measured memory_bytes: 3624
def main():
    nmax = 100000
    n = int(input())
    values = [0] * nmax
    a = [int(v) for v in input().split()]
    for v in a:
        values[v-1] += 1
    asum = sum(a)

    q = int(input())
    for _ in range(q):
        b, c = [int(v) for v in input().split()]
        asum += values[b-1] * (c - b)
        values[c-1] += values[b-1]
        values[b-1] = 0
        print(asum)

main()

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

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

  int N;
  cin >> N;
  vector<int> a(N + 1);
  vector<int> ans(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> a.at(i);
  }
  int counter = 0;
  for(int i = N; i > 0; --i){
    if(i * 2 > N){
      ans.at(i) = a.at(i);
    } else{
      int j = 2;
      int count = 0;
      while(i * j <= N){
        if(ans.at(i * j) == 1){
          count++;
        }
        j++;
      }
      ans.at(i) = (count + a.at(i)) % 2;
    }
    if(ans.at(i) == 1){
      counter++;
    }
  }
  cout << counter <<endl;
  for(int i = 1; i <= N; i++){
    if(ans.at(i) == 1){
      cout << i << " ";
    }
  }
}

Measured memory_bytes: 2560
n=int(input())
a=sorted(list(map(int,input().split())))
ai=a[-1]
aa=ai/2
ans=float("inf")
for i in range(n-1):
    tmp=abs(a[i]-aa)
    if tmp<ans:
        ans=tmp
        aj=a[i]
print(ai,aj)

Measured memory_bytes: 20100
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod=1000000007;
const int inv2=mod+1>>1;
const int Maxn=3005;
int n,q,a[Maxn];
int p[Maxn][Maxn],ans;
int main()
{
	scanf("%d%d",&n,&q);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	for (int i=1;i<=n;++i) for (int j=1;j<=n;++j) p[i][j]=a[i]>a[j];
	for (int q_=0;q_<q;++q_)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		p[x][y]=p[y][x]=1LL*(p[x][y]+p[y][x])*inv2%mod;
		for (int i=1;i<=n;++i) if(i!=x && i!=y)
			p[i][x]=p[i][y]=1LL*(p[i][x]+p[i][y])*inv2%mod,
			p[x][i]=p[y][i]=1LL*(p[x][i]+p[y][i])*inv2%mod;
	}
	for (int i=1;i<=n;++i) for (int j=n;j>i;--j) ans=(ans+p[i][j])%mod;
	for (int i=0;i<q;++i) ans=(ans<<1)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll a, ll b){
	//cout << a << ' ' << b << '\n';
	if(b == 0)
		return 0;
	if(a == b)
		return a;
	ll t = (a-1)/b;
	return 2*t*b + f(b,a-t*b);
}
int main(){
	ll n,x;
	cin >> n >> x;
	cout << n + f(x,n-x) << '\n';
}



Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        long ans=0;
        int right=0;
        long xor=0,sum=0;
        for (int left = 0; left < n; left++) {
            while (right<n&&(xor^a[right])==sum+a[right]){
                xor^=a[right];
                sum+=a[right];
                right++;
            }
            ans+=right-left;
            if(right==left)right++;
            else {
                sum-=a[left];
                xor^=a[left];
            }
        }
        out.println(ans);
    }
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi T(N); REP(i, N) cin >> T[i];
    int M; cin >> M;
    vi P(M), X(M); REP(i, M) cin >> P[i] >> X[i];

    int sum = 0;
    REP(i, N) sum += T[i]; 

    REP(i, M)
    {
        int time = sum;
        time = time - T[P[i]-1] + X[i];
        cout << time << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

using namespace std;

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

typedef vector<int> vi;
typedef long long ll;

void solve() {
  ll N, ans = 0;
  cin >> N;
  if (N % 2 == 0) {
    ll tmp = 10;
    while (tmp <= N) {
      ans += N / tmp;
      tmp *= 5;
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
};

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

int main() {
  int a, x, y;
  cin >> a;
  x = a;

  // ここにプログラムを追記
  while (x > 0) {
    y += x % 10;
    x /= 10;
  }
  if ((a % y) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = Integer.parseInt(sc.nextLine());
			int k = Integer.parseInt(sc.nextLine());
			int x = Integer.parseInt(sc.nextLine());
			int y = Integer.parseInt(sc.nextLine());

			int bill = 0;
			if (n > k) {
				bill = x * k + y * (n - k);
			} else {
				bill = x * n;
			}
			System.out.println(bill);

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n+1]={};
	for(int i=1; i<n+1; i++){
		cin >> a[i];
	}
	int m=0;
	int cnt = 0;
	int b[200010]={};
	for(int i=n; i>0; i--){
		for(int j=i; j<=n; j+=i){
			cnt += b[j];
		}
		cnt%=2;
		if(a[i]!=cnt){
			b[i] = 1;
			m++;
		}
		cnt = 0;
	}
	cout << m << endl;
	for(int i=1; i<n+1; i++){
		if(b[i]) cout << i << endl;
	}
}

Measured memory_bytes: 2560
#include<stdio.h>
#define N_MAX 500000
#define S_MAX 1000000000
#define INFTY S_MAX+1

int L[N_MAX/2+2];
int R[N_MAX/2+2];

long count; // 比較回数

void merge(int *A, int left, int mid, int right)
{
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  // L[0...n1], R[0...n2] を生成
  for (i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (i = 0; i < n2; i++)
    R[i] = A[mid + i];
  
  L[n1] = INFTY; // 番兵を入れる
  R[n2] = INFTY; // 番兵を入れる
  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    count++;  // 比較回数をカウント
    if (L[i] <= R[j]) { // 小さいほうを A にコピー
      A[k] = L[i];
      i = i + 1;
    } else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}
                
void mergeSort(int *A, int left, int right)
{
  int mid;
  
  if (left+1 < right) {
    mid = (left + right)/2;

    mergeSort(A, left, mid);
    mergeSort(A, mid, right);

    merge(A, left, mid, right);
  }
}

int main(void)
{
  int n;
  int A[N_MAX];
  int i;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);

  mergeSort(A, 0, n);

  for(i=0; i<n-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[n-1]);

  printf("%ld\n", count);
  
  return 0;
}



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	int a,b;
	cin>>a>>b;
	if(a<=10)cout<<100*(10-a)+b;
	else cout<<b;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	n,t = map(int,input().split())
	
	cost = 1001
	for i in range(n):
		cn,tn = map(int,input().split())
		if tn <= t :
			cost = min(cost,cn)

	if cost == 1001:
		print("TLE")
	else:
		print(cost)


Measured memory_bytes: 9176
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define int long long

int32_t main() {
 
  int n;
  cin >> n;
  int arr[5], b[5];
  for (int i = 0; i < 5; i++) {
    cin >> arr[i];
    b[i] = (n + arr[i] - 1) / arr[i];
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (i == 0) {
      ans += b[i];
    } else {
      b[i] = max(b[i], b[i - 1]);
      ans += b[i] - (b[i - 1] - 1);
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double l = 2*r*Math.PI;
		double s = r*r*Math.PI;
		System.out.printf("%.10f %.10f%n",s,l);
	}
}


Measured memory_bytes: 28212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int q[10];
    for (int j = 0; j < m; j++) {
        int k;
        cin >> k;

        int t = 0;
        for (int i = 0; i < k; i++) {
            int s;
            cin >> s;
            s--;

            t ^= 1 << s;
        }
        q[j] = t;
    }

    int p[10];
    for (int j = 0; j < m; j++) {
        cin >> p[j];
    }

    int r = 0;
    for (int k = 0; k < 1 << n; k++) {
        int b = 1;
        for (int j = 0; j < m; j++) {
            int t = q[j] & k;
            int c = 0;
            for (int i = 0; i < n; i++) {
                c += (t >> i & 1);
            }
            if (c % 2 != p[j]) {
                b = 0;
                break;
            }
        }
        if (b == 1) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[100][100];
	int b[100];
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 0;i < m;i++)
	{
		scanf("%d",&b[i]);
	}
	int c[100] = {0};
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < m;j++)
		{
			c[i]+=a[i][j]*b[j];
		}
	}
	for(int i = 0;i < n;i++)
	{
		printf("%d\n",c[i]);
	}
	return 0;
} 


Measured memory_bytes: 2776
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
int A,B;
bool cou = false;
cin >> A >> B;
int gohyaku = A / 500;
A -= gohyaku * 500;
if(A <= B)cou = true;
if(cou)cout << "Yes" << endl;
else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	FOR0(n) cin>>a[i]>>b[i]>>c[i];
	int dp[n][3];
	mem(dp,0);
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	FORQ(1,n-1){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	int ans=max(dp[n-1][0],dp[n-1][1]);
	ans=max(ans,dp[n-1][2]);
	cout<<ans;
}



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

ll MAX_N=1e18+7;
ll mod=1e9+7;
ll dp[61][3];

int main(){
	ll N;
	cin>>N;
	dp[60][0]=1;
	for(ll a=59;a>=0;--a){
		for(ll b=0;b<=2;++b){
			for(ll c=0;c<=2;++c){
				ll d=b*2+(N>>a&1)-c;
				if(d<0)continue;
				if(d>2)d=2;
				dp[a][d]+=dp[a+1][b];
				dp[a][d]%=mod;
			}
		}
	}
	ll ret=0;
	for(ll i=0;i<=2;++i)ret+=dp[0][i];ret%=mod;
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
/*alurquiza*/
//R:Walks
#include <bits/stdc++.h>

using namespace std;

const int TAM = 50,MOD = 1e9 + 7;

struct matrix{
    int N,M;
    long long mat[TAM][TAM];

    matrix(int _N = TAM,int _M = TAM,int value = 0){
        N = _N; M = _M;

        for(int i = 0;i < N;i++)
            for(int j = 0;j < M;j++)
                mat[i][j] = value;
    }

    matrix Iden(int _N = TAM){
        matrix ret(_N,_N);

        for(int i = 0;i < _N;i++)
            ret.mat[i][i] = 1;

        return ret;
    }

    friend matrix operator *(const matrix &a,const matrix &b){
        matrix c(a.N,b.M);

        for(int i = 0;i < a.N;i++)
            for(int j = 0;j < b.M;j++)
                for(int k = 0;k < a.M;k++)
                    c.mat[i][j] = (c.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % MOD;

        return c;
    }

    void print(){
        for(int i = 0;i < N;i++)
            for(int j = 0;j < M;j++)
                cerr << mat[i][j] << (j == M - 1 ? '\n' : ' ');
    }

};

matrix pot(matrix base,long long exp){
    matrix ret = ret.Iden(base.N);

    while(exp){
        if(exp & 1)
            ret = ret * base;
        exp /= 2;
        base = base * base;
    }

    return ret;
}

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

//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);

    int N;
    long long K;
    cin >> N >> K;

    matrix MA(N,N);
    for(int i = 0;i < N;i++)
        for(int j = 0;j < N;j++)
            cin >> MA.mat[i][j];

    matrix P_K = pot(MA,K);

    matrix sol = P_K * matrix(N,1,1);
    sol = matrix(1,N,1) * sol;

//    P_K.print();
//    sol.print();

    cout << sol.mat[0][0] << '\n';

    return 0;
}













Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

const int maxn = 110;

char s[maxn];
int a[maxn][maxn];
int n,m;
int dx[5]={0,1,0,-1,0};
int dy[5]={0,0,1,0,-1};

bool judge(int x,int y)
{
	if (a[x][y]==1) return 1;
	for (int i=1;i<=4;i++)
	{
		int xx=x+dx[i],yy=dy[i]+y;
		if (xx<=0 || xx>n || yy<=0 || yy>m) continue;
		if (a[xx][yy]==2) return 1;
	}
	return 0;
}
int main()
{
  cin>>n>>m;
  for (int i=1;i<=n;i++)
  {
  	scanf("%s",s+1);
  	for (int j=1;j<=m;j++)
  	if (s[j]=='.') a[i][j]=1;
  	else a[i][j]=2;
  }
  for (int i=1;i<=n;i++)
  {
  	for (int j=1;j<=m;j++)
  	if (!judge(i,j))
	  {
	  	 cout<<"No";
	  	 return 0;
	   } 
  }
  cout<<"Yes";
  return 0;
}


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

int main() {
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> p(n,k-q);
    map<ll, ll> mp;
    vector<ll> a(q);
    rep(i,q) {
        ll h;
        cin >> h;
        h--;
        mp[h]++;
    }
    rep(i,n) {
        p[i] += mp[i];
        if (p[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 11088
#include<iostream>
using namespace std;
#define S 100
#define INF 1000000
#define WHITE 0;
#define GRAY 1;
#define BLACK 2

int n,a[S][S];

void dijkstra(){
    int minv;
    int d[S],cnd[S];
    int i,v;
    for(i=0;i<n;i++){
        d[i]=INF;
        cnd[i]=WHITE;
    }

    d[0]=0;
    cnd[0]=GRAY;

    while(1){
        minv=INF;
        int u=-1;
        for(i=0;i<n;i++){
            if(minv>d[i]&&cnd[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        cnd[u]=BLACK;
        for(int v=0;v<n;v++){
            if(cnd[v]!=BLACK && a[u][v]!=INF){
                if(d[v]>d[u]+a[u][v]){
                    d[v]=d[u]+a[u][v];
                    cnd[v]=GRAY;
                }
            }
        }
    }

    for(int i=0;i<n;i++){
            cout<<i<<" "<<(d[i]==INF?-1:d[i])<<endl;
    }
}

int main(){
    int i,j,v;
    int k,c,u;
    cin>>n;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)
        a[i][j]=INF;
    }
    for(i=0;i<n;i++){
        cin>>u>>k;
        for(j=0;j<k;j++){
            cin>>v>>c;
            a[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}


Measured memory_bytes: 3108
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

cum_r = [src[0][1]]
for (x1,s1),(x2,s2) in zip(src,src[1:]):
    gain = s2 - (x2 - x1)
    cum_r.append(cum_r[-1] + gain)

best_l = [0]
for (x,s),c in list(zip(src, cum_r))[1::]:
    best_l.append(max(best_l[-1], s - c))

ans = 0
for l,r in zip(best_l, cum_r):
    ans = max(ans, l+r)
print(ans)

Measured memory_bytes: 63284
# coding:utf-8
from __future__ import division, print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass

p, q = 10 ** 9 + 7, 0xffffffff
pow_p = [1]
for i in range(4010):
    pow_p.append(pow_p[-1] * p & q)


def exists(a, b, k):
    n, m = len(a), len(b)

    s = [a[k + i] - a[i] * pow_p[k] & q for i in range(n - k)]
    t = [b[k + i] - b[i] * pow_p[k] & q for i in range(m - k)]
    return len(set(s).intersection(set(t))) > 0


def hash(s):
    t = 0
    yield t
    for c in s:
        t = t * p + ord(c) & q
        yield t
    return


def solve(s, t):
    n, m = len(s), len(t)
    a, b = list(hash(s)), list(hash(t))

    l, r = 0, min(n, m) + 1
    while l + 1 < r:
        m = (l + r) // 2
        if exists(a, b, m):
            l = m
        else:
            r = m
    return l


while True:
    try:
        s = input().strip()
        t = input().strip()
    except EOFError:
        break

    print(solve(s, t))

Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;

//Aの逆元を取る場合、modpow(A, MOD-2, MOD)で求まる
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

//O(K)でnCkを求める
int comb( int N, int K ){
  int X = 1; //分子
  int Y = 1; //分母
  for( int i = N; i > N-K; i-- ){
    X = (X*i)%MOD;
  }
  for( int i = 1; i <= K; i++ ){
    Y = (Y*i)%MOD;
  }
  return X * modpow(Y, MOD-2, MOD)%MOD;
}


signed main() {
  int X, Y;
  cin >> X >> Y;
  
  if( (X+Y)%3 != 0 ){
    cout << 0 << endl;
    return 0;
  }
  
  int m = (2*X-Y)/3;
  int n = X-2*m;
  if( m < 0 || n < 0 ){
    cout << 0 << endl;
    return 0;
  }
  
  int ans = comb(n+m, n);
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define MOD 1000000007
#define MAX 500005
lli p[MAX];
lli arr[MAX];
lli n;
lli a,b;
void DFS1(lli s,  lli dist, unordered_set <lli> &color){
    if(dist %a == 0){
        color.insert(s);
    }
    if(s == 1)
        return;
    DFS1(p[s], dist+1, color);
}
void DFS2(lli s,  lli dist, unordered_set <lli> &color){
    if(dist %b == 0)
        color.insert(s);
    if(s == 1)
        return;
    DFS2(p[s], dist+1, color);
}
bool check(lli a,lli b, lli c){
    if((a-b+c)%2 == 0 && (c+b-a)%2 == 0 && (a+b-c)%2 == 0){
        if((a-b+c) > 0 && (c+b-a)> 0 && (a+b-c)> 0)
            return true;
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    unordered_map <lli,lli> s;
    for(lli i = 1; i<=n; i++){
        s[i*i] = i;
    }
    lli ans = 0;
    for(lli N = 1; N<=n; N++){
        ans = 0;
        for(int i = 1; (i*i)<=2*N; i++){
            for(int j = 1; (j*j) <=2*N; j++){
                if(s[2*N - i*i -j*j]){
                    if(check(i,j,s[2*N - i*i -j*j]))
                    ans++;
                }
                    
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1000000007

int main(){
    int n,h;
    cin >> n >> h;
    priority_queue<int> qa,qb;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        qa.push(a);
        qb.push(b);
    }
    int ans=0;

    while(!qb.empty() and qa.top()<qb.top() and h>0){
        h-=qb.top();
        qb.pop();
        ans++;
    }
    if(h>0) ans+=(h+qa.top()-1)/qa.top();
    cout << ans << endl;
    
}

Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int h,w;
    string s[50];
    cin>>h>>w;
    rep(i,h) cin>>s[i];
    const int x[8]={-1,0,1,-1,1,-1,0,1};
    const int y[8]={-1,-1,-1,0,0,1,1,1};
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            int num=0;
            rep(k,8){
                if(i+y[k]<0||i+y[k]>=h) continue;
                if(j+x[k]<0||j+x[k]>=w) continue;
                if(s[i+y[k]][j+x[k]]=='#') num++;
            }
            s[i][j]=char(num+'0');
        }
    }
    rep(i,h) cout<<s[i]<<endl;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    if 2 * n < m {
        println!("{}", n + ((m - 2 * n) / 4));
    } else {
        println!("{}", m / 2);
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;

const int N = 100005;
queue<int> q;
int n, cnt = 0;
int dis[N], head[N];
bool vis[N];

struct Edge{
	int to, nex, v;
}e[N*10];

inline void add(int x, int y, int z)
{
	e[++ cnt].to = y;
	e[cnt].nex = head[x];
	e[cnt].v = z;
	head[x] = cnt;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++)
		for (int j = 0; j < 10; j ++)
			add(i, (i*10+j)%n, j);
	memset(dis, 0x3f, sizeof dis);
	for (int i = 1; i < 10; i ++){
		q.push(i);
		dis[i] = i; vis[i] = 1;
	}
	while (!q.empty()){
		int u = q.front(); q.pop(); vis[u] = 0;
		for (int i = head[u]; i; i = e[i].nex){
			int v = e[i].to;
			if (dis[v] > dis[u]+e[i].v){
				dis[v] = dis[u]+e[i].v;
				if (vis[v]) continue;
				vis[v] = 1; q.push(v);
			}
		}
	}
	printf("%d\n", dis[0]);
	return 0;
} 

Measured memory_bytes: 13184
import java.util.Scanner;

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

        int times = ((N - 1) / 111) + 1;
        System.out.print(times);
        System.out.print(times);
        System.out.println(times);
    }
}


Measured memory_bytes: 21332
#include <stdio.h>

int main()
{
    char s[5];
    scanf("%s",s);

    if (((s[0] == s[1]) && (s[2] == s[3]) && (s[0] != s[2])) || ((s[0] == s[2]) && (s[1] == s[3]) && (s[0] != s[1])) || ((s[0] == s[3]) && (s[1] == s[2]) && (s[0] != s[1])))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    
}

Measured memory_bytes: 128
import math


def highest_power_of_2(n):
    p = int(math.log(n, 2))
    return p

  
def solve(H):
    power_2 = highest_power_of_2(H)
    ans = 2 * pow(2, power_2) - 1
    print(ans)


def iin(): return int(input())

    
H = iin()
solve(H)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
constexpr int MAX=510000;
ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}


int main()
{
	ll K;
	cin>>K;
	ll N;
	cin>>N;
	vector<ll> A(N);
	vector<ll> distance(N);
	for(int i=0;i<N;i++){
		cin>>A.at(i);
		if(i>0)
		{
			distance.at(i-1)=A.at(i)-A.at(i-1);
		}
		
		
	}
	distance.at(N-1)=abs(K-A.at(N-1)+A.at(0));

	
	
	ll min=9999999999999;
	ll temp=0;
	for(int i=0;i<N;i++){
		temp=K-distance.at(i);
		if(temp<min)
			min=temp;
		
		if(i-1==-1){
			temp=K-distance.at(N-1);
		}
		else{
			temp=K-distance.at(i-1);
		}
		if(temp<min)
			min=temp;

	}
	cout<<min;
	
	
	
	
	return 0;
}  

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

void fill(vector<vector<int>>& color, int x, int y, int pc, int c) {
    if(pc == c) {
        return;
    }
    color[y][x] = c;
    int dx[4] = {0, 1, 0, -1},
        dy[4] = {1, 0, -1, 0};
    for(int i=0; i<4; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < color[0].size() && 0 <= ny && ny < color.size() && color[ny][nx] == pc) {
            fill(color, nx, ny, pc, c);
        }
    }
}

int dfs(vector<vector<int>>& color, int d, int last) {
    int res = 0;
    if(d == 4) {
        fill(color, 0, 0, color[0][0], last);
        fill(color, 0, 0, color[0][0], -1);
        for(int i=0; i<color.size(); ++i) {
            for(int j=0; j<color[i].size(); ++j) {
                if(color[i][j] == -1) {
                    res++;
                }
            }
        }
        return res;
    }
    int pc = color[0][0];
    for(int i=1; i<=6; ++i) {
        auto v2 = color;
        fill(v2, 0, 0, color[0][0], i);
        res = max(res, dfs(v2, d+1, last));
    }
    return res;
}

int main() {
    int h, w, c;
    while(cin >> h >> w >> c, h) {
        vector<vector<int>> color(h, vector<int>(w));
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                cin >> color[i][j];
            }
        }
        cout << dfs(color, 0, c) << endl;
    }
}


Measured memory_bytes: 3104
#include <stdio.h>



int main(void) {

	// 1_7-A Grading
	
	int m,f,r;
	int i;
	char result;

	scanf("%d",&m);
	scanf("%d",&f);
	scanf("%d",&r);

	while( (m!=-1) || (f!=-1) || (r!=-1) ){
		if( (m==-1) || (f==-1) ){
			result = 'F';
		}else if( (m+f) < 30 ){
			result = 'F';
		}else if( (m+f) < 50 ){
			if( 50 <= r ){
				result = 'C';
			}else{
				result = 'D';
			}
		}else if( (m+f) < 65 ){
			result = 'C';
		}else if( (m+f) < 80 ){
			result = 'B';
		}else{
			result = 'A';
		}
		printf("%c\n",result);
		
		scanf("%d",&m);
		scanf("%d",&f);
		scanf("%d",&r);
	}

	return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned LL
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector< PII >
#define VVI vector< VI >
#define PB push_back
#define F first
#define S second
const int INF=1e9;
const int MOD=1e9+7;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C')return 0*puts("Yes");
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = list(map(int, input().split()))

s1 = A * X + B * Y

s2 = C * max(X, Y) * 2

if X > Y:
    s3 = C * (Y * 2) + A * (X - Y)
elif Y > X:
    s3 = C * (X * 2) + B * (Y - X)
else:
    s3 = 10**10

print(min(s1, s2, s3))

Measured memory_bytes: 3064
l, r=map(int, input().split())
if r-l>672:
	p=0
else:
	p=2019
	for i in range(l, r):
		for j in range(i+1, r+1):
			p=min(p, (((i%2019)*(j%2019))%2019))
			if not p:
				break
		if not p:
			break
print(p)

Measured memory_bytes: 3060
n = int(input())
list_A = list(map(int,input().split()))
list_B = list(map(int,input().split()))
beaten = 0 
for i in range(n):
  if list_A[i]<=list_B[i]:
    list_B[i] -= list_A[i]
    a = min(list_B[i],list_A[i+1])
    list_A[i+1] -= a
    beaten += a+list_A[i]
  else:
    beaten += list_B[i]
print(beaten)
    

Measured memory_bytes: 18624
#include<iostream>
using namespace std;
int BBS(int A[10000],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;
				sw++;

			}

			

		}

	}

	return sw;
}

int main(void){

	int N,sw;
	int A[10000];
	cin >> N;

	for(int i=0;i<N;i++)cin >> A[i];


	sw = BBS(A,N);

	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];
	}
    cout << endl;
	cout << sw << endl;

}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000

vector<int> G[MAX_V];
int match[MAX_V],V;
bool used[MAX_V];
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}


bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||!used[w]&&dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}

int main(){
  int x,y,e,a,b,i;
  cin>>x>>y>>e;
  for(i=0;i<e;i++){
    cin>>a>>b;
    add_edge(a,x+b);
  }
  V=x+y;
  cout << bipartite_matching() << endl;
  return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n1;
string n2;
  string n3;
  cin >> n1;
  cin >> n2;
  cin >> n3;
  char result;
  //cout << n << endl;
  result = n2.at(0);
  cout << "A" << result << "C" << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
string ATGC = "ATGC";
string printer(int in) {
    string ans;
    ans += ATGC[in / 64];
    ans += ATGC[(in /16) % 4];
    ans += ATGC[(in / 4) % 4];
    ans += ATGC[in % 4];
    return ans;
}
ll dp[300][105];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    for(int i = 0; i < 64; i++) dp[i][3] = 1;
    int AGC = 11;
    //cout << printer(14) << endl;
    dp[AGC][3] = 0;
    dp[14][3] = 0;
    dp[35][3] = 0;
    vector<int> NG;
    for(int i = 0; i <= 3; i++) {
        NG.push_back(35 + i * 4);
        NG.push_back(11 + i * 16);
    }
   // NG.push_back(14);
   int timer = 0;
    for(int i = 4; i <= N; i++) {
        for(int before = 0; before < 64; before++) {
            if(before == AGC || before == 14 || before == 35) continue;
            for(int NEW = 0; NEW < 4; NEW++) {
                bool ok = true;
                for(int j = 0; j < NG.size(); j++) {
                    if(NG[j] == (before * 4 + NEW)) ok = false;
                }
                int after = (before * 4 + NEW) % 64;
                if(after == AGC || after == 14 || after == 35) ok = false;
                if(ok) {
                    timer++;
                    //cerr << timer << " " << printer(before * 4 + NEW) << endl;
                    dp[(before * 4 + NEW) % 64][i] += dp[before][i-1];
                    dp[(before * 4 + NEW) % 64][i] %= mod;
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 64; i++) {
        ans += dp[i][N];
    }
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long
#define INF 1e+17
using namespace std;

int n;

int C(int x){
	if(x == 1) return 1;
	int tmp = 1,ret = 0,keta = 1;
	while(tmp <= x){
		int three = min(tmp * 10,x) / 3 - tmp / 3,five = min(tmp * 10 - 1,x) / 5 - (tmp - 1) / 5;
		int tf = min(tmp * 10 - 1,x) / 15 - (tmp - 1) / 15;
		ret += keta * (min(tmp * 10 - 1,x) - (tmp - 1) - three - five + tf) + (three + five) * 4;
		tmp *= 10;
		keta++;
	}
	return ret;
}

signed main(){
	cin >> n;
	int low = 0,up = INF;
	while(up - low > 1){
		int mid = (low + up) / 2;
		if(C(mid) >= n) up = mid;
		else low = mid;
	}
	int num = C(up - 1);
	string s = "";
	for(int i = 0;i < 20;i++){
		if((i + up) % 3 == 0 && (i + up) % 5 == 0) s += "FizzBuzz";
		else if((i + up) % 5 == 0) s += "Buzz";
		else if((i + up) % 3 == 0) s += "Fizz";
		else s += to_string(i + up);
	}
	cout << s.substr(n - num - 1,20) << endl;
	return 0;
}

Measured memory_bytes: 3288
import numpy as np
n, d = map(int, input().split())
a = [[int(i) for i in input().split()] for _ in range(n)]
a = np.array(a)
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        if np.linalg.norm(a[i]-a[j],2).is_integer():
            count += 1
print(count)

Measured memory_bytes: 12432
K = int(input())
MOD = 1000000007

r = 0
cnt = 0
x = 0
while x < 10 ** 6 + 1:
    r = r * 10 + 7
    r %= K

    if r % K == 0:
        print(cnt + 1)
        exit()

    cnt += 1
    x += 1

print(-1)


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

int main()
{
    int n , i;
    string s;
    cin>>s;
    if(s[0]=='A' && s[1]=='A' &&s[2]=='A' ||  s[0]=='B' && s[1]=='B' &&s[2]=='B')
        cout << "No" << endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//	freopen("output.txt", "w", stdout);
int main ()
{
    int r,n,i,j,a;
    vector<int>myvec;
    cin>>r>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        myvec.push_back(a);
    }
    sort(myvec.begin(),myvec.end());
    int x=r-(myvec[n-1]-myvec[0]);
    for(i=1;i<n;i++)
    {
        if(myvec[i]-myvec[i-1]>x)
        {
            x=myvec[i]-myvec[i-1];
        }
    }
    cout<<r-x<<endl;
    return 0;
}



Measured memory_bytes: 1528
#include <stdio.h>

const int MAX_N = 21;
const int MOD = 1000000007;

int n,a[MAX_N][MAX_N],dp[MAX_N][1<<MAX_N];

int f(int i, int j)
{
	if (i==0)
		return a[0][31-__builtin_clz(j)];
	if (dp[i][j]!=-1)
		return dp[i][j];
	int ans=0;
	for (int k=j; k; k^=(k&-k))
		if (a[i][31-__builtin_clz(k&-k)])
		{
			ans+=f(i-1,j^(k&-k));
			if (ans>=MOD)
				ans-=MOD;
		}
	return dp[i][j]=ans;	
}

int main()
{
	scanf("%d",&n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			scanf("%d",&a[i][j]);
	for (int i=0; i<n; i++)
		for (int j=(1<<n)-1; j>=0; j--)
			dp[i][j]=-1;
	printf("%d\n",f(n-1,(1<<n)-1));
	return 0;
}


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

int main() {
	int a;
	
	int sum = 0;
	cin >> a;

	for (int i=1; i <= a; i++) {
		int digit = 0;
		int b = i;
		while ( b != 0) {
			b =  b/10;
			++digit;
		}
		if (1 == (digit % 2)) sum++;
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=150;

int n,a[N],b[N],c[N],d[N];
vector<int> gg[N];
bool vis[N];
int match[N];

bool check(int i,int j) {
	return a[i]<c[j] && b[i]<d[j];
}

bool dfs(int v) {
	vis[v]=1;
	for(int i=0;i<gg[v].size();i++) {
		int u=gg[v][i],w=match[u];
		if(w<0 || !vis[w]&&dfs(w)) {
			match[u]=v;
			return 1;
		}
	}
	return 0;
}

int solve() {
	int res=0;
	memset(match,-1,sizeof(match));
	for(int v=1;v<=n;v++) {
		memset(vis,0,sizeof(vis));
		if(dfs(v)) res++;
	}
	return res;
}

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&a[i],&b[i]);
	}
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&c[i],&d[i]);
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(check(i,j)) {
				gg[i].push_back(j);
			}
		}
	}
	printf("%d\n",solve());
}

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
     cin >> p[i];
  }

  int small = -1;
  for (int i = 0; i <= 101; i++) {
    bool flag = true;
    for (int j = 0; j < N; j ++) {
      if (p[j] == i) {
        flag = false;
        break;
      }
    }
    if (flag) {
      if (small == -1) {
        small = i;
      } else {
        int sabun = X - i > 0 ? X - i : -(X - i);
        int smallsabun = X - small > 0 ? X - small : -(X - small);
        if (sabun < smallsabun) {
          small = i;
        }
      }
    }
  }
  cout << small << endl;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        List<Pair> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int h = scan.nextInt();
            Pair p = new Pair(i, h);
            list.add(p);
        }
        TreeSet<Integer>[] edges = new TreeSet[N];
        for (int i = 0; i < N; i++) {
            edges[i] = new TreeSet<>();
        }
        for (int i = 0; i < M; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            edges[a].add(list.get(b).height);
            edges[b].add(list.get(a).height);
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            Pair p = list.get(i);
            TreeSet<Integer> neibors = edges[p.id];
            if (neibors.size() == 0) {
                ans += 1;
                continue;
            }
            if (neibors.ceiling(p.height) == null) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
    class Pair {
        int id;
        int height;
        Pair(int id, int height) {
            this.id = id;
            this.height = height;
        }
    }
    class PairComaprator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.height != o2.height) {
                return Integer.compare(o1.height, o2.height);
            }
            return Integer.compare(o1.id, o2.id);
        }
    }
}


Measured memory_bytes: 81460
import java.io.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
            String input;
            while (true) {
                input = r.readLine();
                if (input == null) break;
                String[] ns = input.split("[+=]");
                System.out.println(solve(ns));
            }
        } catch (Exception e) {}
    }

    public static String solve(String[] ns) {
        for (int X = 0; X <= 9; X++) {
            BigInteger[] ns_i = new BigInteger[3];
            for (int i = 0; i < ns.length; i++) {
                if (ns[i].length() != 1 && ns[i].charAt(0) == 'X' && X == 0) {
                    ns_i[i] = new BigInteger("999999999999999999");
                    continue;
                }
                ns_i[i] = new BigInteger(ns[i].replace("X", String.valueOf(X)));
            }
            if (ns_i[0].add(ns_i[1]).equals(ns_i[2])) {
                return String.valueOf(X);
            }
        }
        return "NA";
    }
}

Measured memory_bytes: 10000
num = int(input())
num_list = list(map(int,input().split()))

sign = 0

for i in range(0,num):
  if num_list[i]%2 == 0:
    if not (num_list[i]%3 == 0 or num_list[i]%5 == 0):
      sign = 1

if sign == 0:
  ans = "APPROVED"
elif sign == 1:
  ans = "DENIED"
  
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    double A, B, H, M;

    std::cin >> A >> B >> H >> M;

    double angle = M * 2.0 * M_PI / 60.0 - (H * 2.0 * M_PI / 12.0 + M * M_PI / 6.0 / 60.0);
    //if (angle >= M_PI)
    //    angle -= M_PI;

    double dist = A * A + B * B - 2.0 * A * B * cos(angle);
    dist = sqrt(dist);

    cout << std::setprecision(20) << std::fixed << dist << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 9999999
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int A, B;
	cin >> A >> B;
	cout << A*B - (A + B) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
hs = list(map(int, input().split()))

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

# 再帰が深すぎてStack Overflowになる
# def dp(i):
#     if tbl[i] != INF:
#         return tbl[i]
#     else:
#         res = min(dp(i-2)+abs(hs[i]-hs[i-2]),
#                  dp(i-1)+abs(hs[i]-hs[i-1]))
#         tbl[i] = res
#         return res

# print(dp(N-1))

# forループを回して逐次的にテーブルを埋めていく
for i in range(2,N):
    tbl[i] = min(tbl[i-2]+abs(hs[i]-hs[i-2]),
                 tbl[i-1]+abs(hs[i]-hs[i-1]))

print(tbl[N-1])

Measured memory_bytes: 13980