akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

ll d[41][1<<17];
int main() {
	ll chk=1;
	int n,x,y,z;
	scanf("%d%d%d%d",&n,&x,&y,&z);
	chk=(chk<<x)+1;
	chk=(chk<<y)+1;
	chk<<=z-1;
	int M=1<<(x+y+z);
	d[0][0]=1;
	fup(i,0,n-1,1)
	{
		fup(j,0,M-1,1)
		{
			fup(k,0,9,1)
			{
				int nj=(((j<<1)+1)<<k)%M;
				if((chk&nj)!=chk)
					d[i+1][nj]=(d[i+1][nj]+d[i][j])%MOD;
			}
		}
	}
	ll ans=POW(10,n);
	fup(i,0,M-1,1)ans=(ans-d[n][i]+MOD)%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 41216
#include <cstdio>
#include <cassert>
#include <vector>
using namespace std;

int n;
int d;
char S[1001];
vector<int> ones;

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

    for (int i=0; i<n && d>0; i++) {
        if (S[i] == '1') ones.push_back(i);
        else if (S[i] == '0') {
            S[i] = '1';
            --d;
        }
    }

    while (d > 0) {
        int idx = ones.back();
        assert(S[idx] == '1');
        S[idx] = '0';
        d--;
        ones.pop_back();
    }

    puts(S);
}

Measured memory_bytes: 1040
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;

void dfs(int x, int y, int h, int w, vector<vector<int> > &f){
	
	f[x][y] = 0;
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			int x2 = x+i;
			int y2 = y+j;
			if((0<=x2 && x2<=h-1) && (0<=y2 && y2<=w-1)){
				if(f[x2][y2]) dfs(x2, y2, h, w, f);
			}
		}
	}
	
	return;
}

bool solve(){
	int w, h;
	cin>> w>> h;
	if(w==0 && h==0) return false;
	
	vector<vector<int> > field(h, vector<int>(w,0));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int c;
			cin>> c;
			field[i][j] += c;
		}
	}
	
	int ans = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(field[i][j]){
				dfs(i, j, h, w, field);
				ans++;
			}
		}
	}
	
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1484
#include <stdio.h>

int main() {
	int i, n, s[3], x = 0;

	scanf("%d", &n);

	for (i = 2; i >= 0; i--) {
		s[i] = n % 10;
		n /= 10;
	}

	for (i = 0; i < 3; i++) x += s[i];

	printf("%d\n", x);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

    int a,b,c,i,z,sum = 0; //iはfor文用兼ｃを割る値 　zは余りがあるかどうか　sumは合計

    scanf("%d %d %d",&a,&b,&c);

    for(i=a;i<=b;i++){
        z = c%i;
        if(z == 0)
            sum++;


    }

    printf("%d\n",sum);


        return 0;


}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int K, X;

int main() {
    cin >> K >> X;

    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

enum EVENT{ORDER, COOKED};

class Event
{
public:
	int c,t,s,id;
	EVENT e;
	
	Event(int c, int t, int s, int id, EVENT e)
	:c(c),t(t),e(e),s(s),id(id)
	{}
	
	bool operator<(const Event& a) const
	{
		if(t!=a.t) return t>a.t;
		if(e!=a.e) return e<a.e;
		if(c==a.c) return s>a.s;
		return c>a.c;
	}
};

class Order
{
public:
	int id,pt;
	Order(int id, int pt)
	:id(id),pt(pt)
	{}
	
	bool operator<(const Order& a) const
	{
		if(pt!=a.pt) return pt>a.pt;
		return id<a.id;
	}
};

int main()
{
	bool f=true;
	int M,N;
	while(cin >> M >> N, (M||N))
	{
		if(!f) cout << endl;
		f=false;
		
		int limit[20], time[20];
		map<string, int> d;
		for(int i=0; i<M; i++)
		{
			int l,t;
			string n;
			cin >> n >> l >> t;
			d[n]=i;
			
			limit[i]=l; time[i]=t;
		}
		
		priority_queue<Event> q;
		
		int order[100],cooked[100]={0},cookid=-1,cooking=0,cooktime=-1,served[100],pretime=-1;
		for(int i=0; i<N; i++)
		{
			int t,o;
			cin >> t >> o;
			order[i]=o;
			vector<Order> seq;
			for(int j=0; j<o; j++)
			{
				string n;
				cin >> n;
				seq.push_back(Order(d[n], time[d[n]]));
			}
			sort(seq.begin(), seq.end());
			for(int j=0; j<seq.size(); j++)
			{
				q.push(Event(i,t,j,seq[j].id,ORDER));
			}
		}
		while(!q.empty())
		{
			Event e=q.top(); q.pop();
			if(e.e==ORDER)
			{
				if(cookid==e.id&&cooking<limit[e.id]&&pretime==e.t||cooking==0)
				{
					int tm=e.t+time[e.id];
					pretime=e.t;
					cooktime=tm;
					cooking++;
					cookid=e.id;
					q.push(Event(e.c, tm,e.s, e.id,COOKED));
				}
				else
				{
					q.push(Event(e.c, cooktime,e.s, e.id,e.e));
					continue;
				}
			}
			else
			{
				cooking--;
				cooked[e.c]++;
				if(cooked[e.c]==order[e.c])
					served[e.c]=e.t;
			}
		}
		
		for(int i=0; i<N; i++)
			cout << served[i] << endl;
	}
}

Measured memory_bytes: 976
#include <stdio.h>

int main()
{
	int a, b, c, cnt = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(int i = a; i <= b; ++i)
	{
		if(c % i == 0)
		{
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
long long n,a,b;
int main()
{

    cin>>n>>a>>b;
    if(b-a<=2) cout<<n+1<<endl;
    else
        if(a-1>n) cout<<n+1<<endl;
        else
        {
            long long ans=a+(b-a)*((n-(a-1))/2);
            if((n-(a-1))%2==1) ++ans;
            cout<<ans<<endl;
        }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int count = 0;
  
  while(true){
    rep(i,n){
      if(a[i]%2){
        cout << count << endl;
        return 0;
      }
      a[i] /= 2;
    }
    count++;
  }
  return 0;
}

Measured memory_bytes: 256
while True:
    a, op,b = map(str,input().split())
    if op == '?':
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))



Measured memory_bytes: 5592
#include<stdio.h>

int main(void)

{

   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 <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
const int mod = 1e9+7;
int main(){
	int n,m;
	cin >> n >> m;
	ll ans = 1;

	if(abs(n-m) == 0){
		ans = 2;
		reps(i,1,n+1){
			ans = (ans*i) %mod; 
		}
		reps(i,1,m+1){
			ans = (ans*i) %mod; 
		}
		cout << ans << endl;
	}else if(abs(n - m) == 1){
		reps(i,1,n+1){
			ans = (ans*i) %mod; 
		}
		reps(i,1,m+1){
			ans = (ans*i) %mod; 
		}
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb(i) push_back(i)
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);}
bool fd(const pair<int,int> &a,const pair<int,int> &b){return (a.first>b.first);}
bool sd(const pair<int,int> &a,const pair<int,int> &b){return (a.second>b.second);}
#define max_n (ll)(1e4+5)


int main(){
   fio;
   ll n,m,k;
   cin>>n>>m>>k;
   cout<<(ll)(n-m+1)*(n-k+1);
   rr;}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, count int
	)
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

int main() {
	std::string cur;
	std::cin>>cur;
	switch(cur[0]) {
		case 'S': std::cout<<"Cloudy"; break;
		case 'C': std::cout<<"Rainy"; break;
		case 'R': std::cout<<"Sunny"; break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		if(n == 0 || m == 0) break;
		printf("%d\n",(n - 1) * (m - 1));
		}
	return 0;
	}

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

using namespace std;

int n, k, pos, ans;

int main(){
	cin >> n >> k;
	for (int i = 0, a; i < n; ++i)
		cin >> a;
	cout << (n - 1 + k - 2) / (k - 1) << '\n';
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto x = readln.chomp.to!int;
  int sum;
  auto i = 1;
  while (sum < x) {
    sum += i;
    i++;
  }
  (i-1).writeln;
}


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

int main() {
  	ll a, b, c, d;
  	cin >> a >> b >> c >> d;
  
  	ll ac=a*c, ad=a*d, bc=b*c, bd=b*d;
  	ll ans = max(max(ac, ad), max(bc, bd));
  	cout << ans << endl;
  	return 0;  
}


Measured memory_bytes: 3528
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>


using namespace std;

int main(){
	int A, B, i, j, w = 1, b = 1, x = 0;
	char S[100][100], c1, c2;
	scanf("%d %d", &A, &B);
	if (A > B){
		c1 = '#';
		c2 = '.';
	}
	else{
		c1 = '.';
		c2 = '#';
	}
	for (i = 0; i < 100; i++){
		for (j = 0; j < 100; j++){
			S[i][j] = c1;
		}
	}
	S[0][0] = c2;
	
	for (i = 0; i < 25; i++){
		for (j = 0; j < 25; j++){
			if (b < B&&w < A){
				S[4 * i + 1][4 * j + 1] = c2;
				S[4 * i + 1][4 * j + 2] = c2;
				S[4 * i + 1][4 * j + 3] = c2;
				S[4 * i + 2][4 * j + 1] = c2;
				S[4 * i + 2][4 * j + 3] = c2;
				S[4 * i + 3][4 * j + 1] = c2;
				S[4 * i + 3][4 * j + 2] = c2;
				S[4 * i + 3][4 * j + 3] = c2;
				b++;
				w++;
			}
			else if (b < B || w < A){
				S[4 * i + 1][4 * j + 1] = c2;
				b++;
				w++;
			}
		}
	}
	printf("100 100\n");
	for (i = 0; i < 100; i++){
		for (j = 0; j < 100; j++){
			printf("%c", S[i][j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll x;cin >> x;
  int sum = 0;
  while(x){
    int y = x%10;
    x/=10;
    if(x==0) sum += y;
    else{
      sum += 9;
      if(y!=9)--x;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string n;
ll k, result;
map<pair<string, int>, int> save;
ll C(ll, ll);
ll solve(string, ll);
int main()
{
    save.clear();
    cin>>n>>k;
    result = solve(n, k);
    cout<<result<<"\n";
}
ll C(ll a, ll b)
{
    if(a==b) return 1;
    if(b==1) return a;
    return C(a-1, b)+C(a-1, b-1);
}
ll solve(string a, ll b)
{
    if(save.find({a, b})!=save.end()) return save[{a, b}];
    if(a.length()<b) return 0;
    while(a[0]=='0') a = a.substr(1, a.length()-1);
    if(a.length()==0) return 0;
    ll ans = 0;
    if(b==1)
        ans = 9*(a.length()-1)+a[0]-'0';
    else
    {
        string tmp = "";
        for(int i = 0; i<a.length()-1; ++i) tmp+='9';
        ans += solve(tmp, b);
        ans += solve(tmp, b-1) * (a[0]-'1');
        ans += solve(a.substr(1, a.length()-1), b-1);
    }
    return save[{a, b}] = ans;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
 static class Team implements Comparable<Team> {
	final Integer num;
	final int[]   tryCounter;
	int           clear = 0;
	int           pena  = 0;

	Team(int num, int pCount) {
	 this.num = Integer.valueOf(num);
	 tryCounter = new int[pCount];
	}

	@Override
	public int compareTo(Team o) {
	 int result = Integer.signum(o.clear - clear);
	 if (result == 0) result = Integer.signum(pena - o.pena);
	 if (result == 0) result = Integer.signum(num - o.num);
	 return result;
	}

	@Override
	public String toString() {
	 return String.format("%d %d %d", num, clear, pena);
	}
 }

 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	List<Team> teams = new ArrayList<Main.Team>();
	do {
	 teams.clear();
	 final int T = in.nextInt();
	 final int P = in.nextInt();
	 final int R = in.nextInt();
	 for (int i = 0; i < T; i++) {
		teams.add(new Team(i + 1, P));
	 }
	 for (int r = 0; r < R; r++) {
		recored(
		  teams.get(in.nextInt() - 1),
		  in.nextInt(),
		  in.nextInt(),
		  in.next());
	 }
	 Collections.sort(teams);
	 for (Team team : teams) {
		System.out.println(team);
	 }
	} while (in.hasNext());
 }

 private static void recored(
	 Team team, int pID, int time, String next) {
	if (next.equals("CORRECT")) {
	 team.clear++;
	 team.pena += team.tryCounter[pID - 1] * 1200 + time;
	} else {
	 team.tryCounter[pID - 1]++;
	}

 }
}

Measured memory_bytes: 13000
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    int dex[3] = {-1, -1, -1};
    for (int i = 0; i < M; i++){
        int digit,num;
        cin>>digit>>num;
        if (dex[digit-1] == -1 || dex[digit-1] == num) {
            dex[digit-1] = num;
        }else {
            cout<<"-1"<<endl;
            return 0;
        }
    }
     if (N > 1 && dex[0] == 0) {
           std::cout << -1 << std::endl;
           return 0;
       }
    
       for (int i = 0; i < N; ++i) {
           std::cout << (dex[i] != -1 ? dex[i] : N > 1 && i == 0 ? 1 : 0);           
       }
       std::cout << std::endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	d, t, s = rli()
	x = d/s 
	print("Yes" if x <= t else "No")
	stdout.close()

if __name__ == "__main__":
	main()

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

void replace(string &s, char c) {
    for (size_t p = s.find("ABC"); p != string::npos; p = s.find("ABC", p + 2)) {
        s[p] = c;
        s[p + 1] = s[p + 2] = '@';
    }
    s.erase(remove(s.begin(), s.end(), '@'), s.end());
}

string replace2(string &s, char c) {
    string res;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == c) res += "ABC";
        else res += s[i];
    }
    return res;
}

bool solve(string s) {
    string t = s;
    string log;
    while (t != "ABC" && t.find("ABC") != string::npos) {
        if (t.substr(0, 3) == "ABC") {
            replace(t, 'A');
            log += 'A';
        } else if (t.substr(t.size() - 3, 3) == "ABC") {
            replace(t, 'C');
            log += 'C';
        } else {
            replace(t, 'B');
            log += 'B';
        }
    }
    if (t != "ABC") return false;
    reverse(log.begin(), log.end());
    for (int i = 0; i < log.size(); i++) {
        t = replace2(t, log[i]);
    }
    return s == t;
}

int main() {
    string s;
    while (cin >> s) {
        puts(solve(s) ? "Yes" : "No");
    }
}

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

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

    vector<string> str(n); //declaring an array of string

    for(int i=0; i<n; i++) cin>>str[i];//taking n string inputs
    sort(str.begin(), str.end());//sorting n strings lexicographically and "sort()" is a built in function of C++
    for(int i=0; i<n; i++) cout<<str[i];//printing the sorted strings

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main() {
	int N, M, ans = 0;
	map<int, int> edge;
	bool graph[51][51], n = true;
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) {
		edge[i] = 0;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			graph[i][j] = true;
		}
	}
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		graph[a][b] = false;
		graph[b][a] = false;
		++edge[a];
		++edge[b];
	}
	while (n) {
		n = false;
		for (int i = 1; i <= N; ++i) {
			if (edge[i] == 1) {
				edge[i]--;
				++ans;
				n = true;
				for (int j = 1; j <= N; ++j) {
					if (!graph[i][j]) {
						graph[i][j] = true;
						graph[j][i] = true;
						edge[j]--;
						break;
					}
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n; cin >>n;
  vector<int> a(n),b(n),c(n);
  rep(i, n) cin >>a.at(i); rep(i, n) cin >>b.at(i); rep(i, n) cin >>c.at(i);
  sort(all(a)); sort(all(b)); sort(all(c));
  vector<int> ba(n),cb(n);
  // ba[i]...a[j]<b[i]となるjの数。広義単調増加
  // cb[i]...b[j]<c[i]となるjの数。広義単調増加
  rep(i, n){
    int tmp = lower_bound(all(b), c[i]) - b.begin();
    cb[i] = tmp;
  }
  rep(i, n){
    int tmp = lower_bound(all(a), b[i]) - a.begin();
    ba[i] = tmp;
  }
  vector<ll> basum(n+1); // ba[i]の累積和
  rep(i, n) basum[i+1] = basum[i] + ba[i];
  ll res = 0;
  rep(i, n){
    int x = cb[i];
    if (x < 1) continue;
    // このときc[i]より小さい値はb[0]～b[x]となる
    // つまりba[0]～ba[x]を全て足したい
    res += basum[x];
  }
  cout <<res <<endl;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int median;
    ll ans = 0;
    vector<int> v;
    rep(i, n) {
      int a;  cin >> a;
      v.push_back(a - (i + 1));
    }
    sort(v.begin(), v.end());
    median = v[(n + 1) / 2 - 1];
    rep(i, n) {
      ans += abs(v[i] - median);
    }
    cout << ans << '\n';

    return 0;
}


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

static const int N = 100;
//static const int white = 0;
//static const int gray = 1;
//static const int black = 2;
static const int inf = (1 << 30);

int n, m[N][N];
int d[N];
//color[N];

void bfs(int s) {
	queue<int> q;
	for (int i = 0; i < n; i++) {
		//color[i] = white;
		d[i] = inf;
	}
	d[s] = 0;
	q.push(s);
	//color[s] = gray;
	while (!q.empty()) {
		for (int  i = 0; i < n; i++) {
			if (m[s][i] == 1 && d[i] == inf) {
				q.push(i);
				d[i] = d[s] + 1;
			}
		}
	//	color[s] = black;
		q.pop();
		s = q.front();
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			m[i][j] = 0;
		}
	}	
	int u, k, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			m[u][v] = 1;
		}
	}
	bfs(0);
	for (int i = 0; i < n; i++) {
		if (d[i] == inf)
			cout << i + 1 << " " << -1 << endl;
		else
			cout << i + 1 << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3128
#include <cstdio>

#pragma warning(disable: 4996)

#define MAX_N 2000000
#define MAX_E 10001

int N, A[MAX_N], C[MAX_E], cnt;

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

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

		C[A[i]]++;
	}

	for (int i = 0; i < MAX_E; i++)
	{
		for (int j = 0; j < C[i]; j++)
		{
			if (cnt++) { printf(" "); }

			printf("%d", i);
		}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 10504
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int e()
{
  return -1;
}

int op(int a, int b)
{
  return max(a, b);
}

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

  segtree<int, op, e> seg(n);

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    seg.set(i, x);
  }

  for (int i = 0; i < q; i++) {
    int t, a, b;
    cin >> t >> a >> b;
    a--;
    switch (t) {
    case 1: seg.set(a, b); break;
    case 2: cout << seg.prod(a, b) << endl; break;
    case 3: cout << seg.max_right(a, [&](auto x){return x < b;}) + 1 << endl; break;
    }
  }
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

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

	int n, a[200000];
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	ll ans = 0;
	map<int, int> cnt;
	for(int i = 0; i < n; i++) {
		cnt[i + a[i]]++;
		ans += cnt[i - a[i]];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21428
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => { content += buf; })
process.stdin.on('end', () => {
  const [a, b] = content.split(' ').map(n => parseInt(n, 10));
  if (a < b) {
    console.log('a < b');
  } else if (a > b) {
    console.log('a > b');
  } else {
    console.log('a == b');
  }
});


Measured memory_bytes: 15288
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct LazySegmentTree {
private:
	int n; // length of node, lazy
	vector<ll> node, lazy;
	/* propagete the laziness of the k-th node. */
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k] / 2;
				lazy[2 * k + 2] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}
public:
	LazySegmentTree() {};
	/* constructor. v is the data. */
	LazySegmentTree(vector<ll>& v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, 0);

		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}
	/* add x to s[a],s[a+1],...,s[b-1] */
	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] += ((ll)r - l) * x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}
	/* calculate the sum of s[a],s[a+1],...,s[b-1] */
	ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[k];
		ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int main() {
	int N; string S;
	cin >> N >> S;
	vector<LazySegmentTree> segs(26);
	vector<vector<ll>> alp(26, vector<ll>(N, 0));
	for (int i = 0; i < N; ++i)
		alp[S[i] - 'a'][i] = 1;
	for (int i = 0; i < 26; ++i)
		segs[i] = LazySegmentTree(alp[i]);
	int Q; cin >> Q;
	while (Q--) {
		int q; cin >> q;
		if (q == 1) { // update クエリ
			int iq; char cq;
			cin >> iq >> cq; --iq;
			segs[S[iq] - 'a'].add(iq, iq + 1, -1);
			segs[cq - 'a'].add(iq, iq + 1, 1);
			S[iq] = cq;
		}
		else { // get クエリ
			int l, r; cin >> l >> r;
			--l;
			int res = 0;
			for (int i = 0; i < 26; ++i)
				res += segs[i].getsum(l, r) ? 1 : 0;
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 528740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b)+min(c,d) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, 0, m) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, 0, n) rep(k, 0, m) cin >> a[i][k];

    int ans = 0;
    rep(i, 0, n)
    {
        int score = c;
        rep(k, 0, m)
        {
            score += a[i][k] * b[k];
        }

        if (score > 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=55;
int n;
namespace Gr {
	vector<int> G[N];
	queue<int> que;
	int du[N];
	void init() { for(int i=1;i<=n;++i) G[i].clear(),du[i]=0; }
	void ad(int x,int y) {
//		cout<<x<<' '<<y<<endl;
		G[x].PB(y);
		du[y]++;
	}
	bool sol() {
		int cnt=0;
		for(int i=1;i<=n;++i) if(!du[i]) que.push(i);
		while(!que.empty()) {
			cnt++; int u=que.front(); que.pop();
			for(int i=0;i<G[u].size();++i) {
				int v=G[u][i];
				if(!(--du[v])) que.push(v);
			}
		}
		return cnt==n;
	}
}
vector<int> G[2][N];
int fa[2][N];
int mp[2][N][N];
int flg;
int dfs2(int u) {
	int tot=1;
	for(int v=1;v<=n;++v)
		if(fa[0][v]==u&&fa[1][v]==u)
			tot+=dfs2(v);
	return tot;
}
void dfs(int p,int u,int last) {
	fa[p][u]=last;
	for(int i=0;i<G[p][u].size();++i)
		if(G[p][u][i]!=last) dfs(p,G[p][u][i],u);
}
int vis[N],tot_siz;
void check(int u) {
	if(vis[u]) return; tot_siz++,vis[u]=1;
	for(int i=0;i<G[0][u].size();++i) check(G[0][u][i]);
}
int sol(int rt) {
//	cout<<"SOL:"<<rt<<endl;
	for(int d=0;d<2;++d)
		for(int u=1;u<=n;++u) {
			G[d][u].clear();
			for(int v=1;v<=n;++v) if(mp[d][u][v])
				G[d][u].PB(v);
		}
	{
		tot_siz=0;
		for(int i=1;i<=n;++i) vis[i]=0;
		check(1);
		if(tot_siz<n) return 0;
	}		
		
	dfs(0,rt,0);
	dfs(1,rt,0);
	Gr::init();
	int cnt=0;
	for(int i=1;i<=n;++i)
		if(fa[0][i]!=fa[1][i]) {
			if(fa[1][fa[1][i]]!=fa[0][fa[1][i]]) Gr::ad(fa[1][i],i);
			if(fa[1][fa[0][i]]!=fa[0][fa[0][i]]) Gr::ad(i,fa[0][i]);
		}
		else cnt++;
	if(dfs2(rt)!=cnt) return 0;
	
	if(Gr::sol()) {
//		cout<<"OK"<<endl;
		flg=1; int cnt=0;
		for(int i=1;i<=n;++i) cnt+=fa[1][i]==fa[0][i];
		return cnt;
	}
  	return 0;
}

int main() {
	int T; rd(T);
	while(T--) {
		flg=0;
		rd(n);
		for(int i=1,x,y;i<n;++i) rd(x),rd(y),mp[0][x][y]=mp[0][y][x]=1;
		for(int i=1,x,y;i<n;++i) rd(x),rd(y),mp[1][x][y]=mp[1][y][x]=1;
		int ans=sol(1);
		for(int u=1;u<=n;++u) {
			int t=0; for(int v=1;v<=n;++v) t+=mp[0][u][v];
			if(t>1) continue;
			for(int v=1;v<=n;++v) if(mp[0][u][v])
				for(int w=1;w<=n;++w) if(!mp[0][u][w]) {
					mp[0][u][v]=mp[0][v][u]=0;
					mp[0][u][w]=mp[0][w][u]=1;
					ans=max(ans,sol(u)-1);
					mp[0][u][v]=mp[0][v][u]=1;
					mp[0][u][w]=mp[0][w][u]=0;
				}
		}
		if(!flg) printf("-1\n");
		else printf("%d\n",n-ans);
		for(int d=0;d<2;++d)
			for(int i=1;i<=n;++i)
				for(int j=1;j<=n;++j)
					mp[d][i][j]=0;
	}
	return 0;
}


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



int main()
{

long long int n;
cin >> n;
long long int a,b;
long long int ans;
cin >> a >> b;
if((a + b) % 2 == 0){
ans =  (b -a) / 2;
}else if(b - a == 1){
    if(a - 1<= n -b){
    ans = a;
    }else{
    ans = n - b + 1;
    }
}else{
    if(a - 1<= n -b){
        ans = a   + ((b- a - 1) / 2);
    }else{
        ans = n - b + 1 +  (( b -a  -1 ) / 2);
    }
}
cout << ans << endl;
   return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	char T[98 + 1];
	char H[98 + 1];
	int n,tc,hc,i,j;

	scanf("%d",&n);

	tc = hc = 0;

	for (i = 0; i < n; i++)
	{
		scanf("%98s",T);
		scanf("%98s",H);

		j = 0;

		while (T[j] != '\0' && H[j] != '\0' && T[j] == H[j]) j++;

		if (T[j] == '\0' && H[j] == '\0')
		{
			tc++; hc++;
		}
		else
		{
			if ((T[j] - H[j]) > 0) tc += 3;
			else hc += 3;
		}
	}

	printf("%d %d\n",tc,hc);

	return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define printP(x) "(" << (x).first << ", " << (x).second << ")"
#define mod 1000000007
using namespace std;
typedef pair<llint, llint> P;

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint b, w;
llint diff[200005];

int main(void)
{
	cin >> b >> w;
	make_fact();
	
	for(int i = b; i < w+b; i++){
		llint x = comb(i-1, b-1) * modpow(modpow(2, i), mod-2) % mod;
		diff[i] += x, diff[i] %= mod;
		diff[i+1] += mod-x, diff[i+1] %= mod;
		x *= (b-1) * modpow(i-1, mod-2) % mod, x %= mod;
		diff[1] += x, diff[1] %= mod;
		diff[i] += mod-x, diff[i] %= mod;
	}
	for(int i = w; i < w+b; i++){
		llint x = comb(i-1, w-1) * modpow(modpow(2, i), mod-2) % mod;
		diff[i+1] += x, diff[i+1] %= mod;
		x *= (i-w) * modpow(i-1, mod-2) % mod, x %= mod;
		diff[1] += x, diff[1] %= mod;
		diff[i] += mod-x, diff[i] %= mod;
	}
	
	for(int i = 1; i <= w+b; i++){
		diff[i] += diff[i-1], diff[i] %= mod;
		cout << diff[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 6912
//created by pyoxiao on 2020/04/12
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int n;
void solve() {
    scanf("%d", &n);
    bool flag = 0;
    while(n) {
        if(n % 10 == 7) flag = 1;
        n /= 10;
    }
    if(flag) puts("Yes");
    else puts("No");
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] loads = new int[N+1];
		for(int i=0;i<M;i++) {
			int a = sc.nextInt();
			loads[a]++;
			int b = sc.nextInt();
			loads[b]++;
		}

		for(int i=1;i<=N;i++) {
			System.out.println(loads[i]);
		}
	}

}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, k; cin >> n >> k;
	int h[n];
	for(int i=0; i<n; i++)
		cin >> h[i];
	int dp[n];
	for(int i=0; i<n; i++)
		dp[i] = MAX;
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i=2; i<n; i++){
		for(int j=1; j<=k; j++){
			if(i-j >= 0)
				dp[i] = min(abs(h[i] - h[i-j]) + dp[i-j], dp[i]);
		}
	}
	cout << dp[n-1] << "\n";
	return 0;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn is_odd(n: u32) -> bool {
    n % 2 == 1
}

fn main() {
    let a = read::<u32>();
    let b = read::<u32>();
    let res = vec![a, b].iter().all(|&i| is_odd(i));

    match res {
        true => println!("Odd"),
        _ => println!("Even")
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int A, B;
int main() {
	cin >> A >> B ;
	if (A < 10 && B < 10) {
		cout << A * B;
	} else {
		cout << -1;
	}
	return 0;
}


Measured memory_bytes: 256
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

from itertools import combinations
N=int(input())

prime_list=primes(55555)
id=4
ans=[prime_list[i] for i in range(len(prime_list)) if prime_list[i]%5==2]

print(" ".join(map(str,ans[:N])))

Measured memory_bytes: 3700
import java.util.*

fun main(args: Array<String>){
  val sc = Scanner(System.`in`)
  val k = sc.nextInt()
  val s = sc.nextInt()
  
  var ans = 0
  for(x in 0..k){
    for(y in 0..k){
      val tmp = s - (x + y)
      if(tmp > s || tmp < 0)break
      if(tmp <= k)ans++
    }
  }
  print(ans)
}

Measured memory_bytes: 31256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  int N;
  ll x;
  cin >> N >> x;
  vector<ll> a(N);
  ll sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll count = 0;
  int ans = 0;
  bool b = true;
  int k;
  for(int i = 0; i < N; i++) {
    if(x - count >= a[i]) {
      count += a[i];
      ans++;
    }
    else {
      b = false;
      break;
    }
  }
  if(b && count != x) {
    ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int ans=0,N;
  cin >> N;

  int h=0,hb=0;

  for(int i=0;i<N;i++){
    cin >> h;
    ans+=max(0, h-hb);
    hb=h;
  }

  cout << ans << endl;

  return 0;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int tab[100],table[100],a,b;
int main(){
	memset(table,0,sizeof(table));
	scanf("%d%d",&a,&b);
	if(a==0&&b==0) return 0;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			int n;
			scanf("%d",&n);
			table[j]+=n;
		}
	}
	for(int i=0;i<b;i++) tab[i]=table[i];
	sort(tab,tab+b);
	for(int j=b-1;j>=0;j--){
		for(int i=0;i<b;i++){
			if(table[i]==tab[j]){
				if(j!=b-1) printf(" ");
				printf("%d",i+1);
				table[i]=-1;
				break;
			}
		}
	}
	printf("\n");
	main();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;

int main(){
    ll a,b;
    cin >> a >> b;
    if(a==1 || b==1){
        cout << 1 << '\n';
        return 0;
    }
    cout << (a*b+1)/2 << '\n';


    return 0;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int,input().split())
edge = [[] for i in range(N)]
visited = [0]
count = 0

for i in range(M):
  a, b = map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
  
def DFS(n):
  global count
  if len(visited) == N:
    count += 1
    return
  else:
    for i in edge[n]:
      if not(i in visited):
        visited.append(i)
        DFS(i)
        visited.remove(i)
    return

DFS(0)

print(count)

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

struct LowestCommonAncestor {
    using Graph = vector<vector<int>>;
    const int t_inf = numeric_limits<int>::max();
    pair<int, int> id = make_pair(t_inf, INT_MAX);
    int n;
    vector<pair<int, int>> data;
    vector<int> idx;

    LowestCommonAncestor(Graph G, int s = 0) : idx(G.size(), -1), n(1) {
        vector<pair<int, int>> p;
        EulerTour(G, s, s, 0, p);
        int sz = p.size();
        for (int i = sz-1; i >= 0; i--) idx[p[i].second] = i;
        while (n < sz) { n *= 2; }
        data.resize(2*n-1, id);
        for (int i = 0; i < sz; i++) data[i+n-1] = p[i];
        for (int i = n-2; i >= 0; i--) data[i] = min(data[i*2+1], data[i*2+2]);
    }

    void EulerTour(const Graph &G, int now, int par, int dep, vector<pair<int, int>> &path) {
        path.emplace_back(dep, now);
        for (auto nxt : G[now]) if (nxt != par) {
            EulerTour(G, nxt, now, dep + 1, path);
            path.emplace_back(dep, now);
        }
    }

    inline pair<int, int> query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return data[k];
        pair<int, int> vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        pair<int, int> vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }

    int ancestor (int a, int b) {
        int l = min(idx[a], idx[b]), r = max(idx[a], idx[b]);
        return query(l, r + 1).second;
    }

    int distance(int a, int b) {
        int l = min(idx[a], idx[b]), r = max(idx[a], idx[b]);
        int an = query(l, r + 1).first;
        int d1 = data[idx[a]+n-1].first, d2 = data[idx[b]+n-1].first;
        return (d1 + d2 - an*2);
    }
};



int main() {
    int n, k, q, s, t;
    scanf("%d", &n);
    vector<vector<int>> g(n);
    for (int v = 0; v < n; v++) {
        scanf("%d", &k);
        for (int i = 0; i < k; i++) {
            int u; scanf("%d", &u);
            g[v].emplace_back(u);
            g[u].emplace_back(v);
        }
    }
    
    LowestCommonAncestor lca(g, 0);
    scanf("%d", &q);
    while(q--) {
        scanf("%d%d", &s, &t);
        printf("%d\n", lca.ancestor(s, t));
    }
    return 0;
}


Measured memory_bytes: 23156
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main() {
    long long h, w;
    int n;

    cin >> h >> w >> n;

    long long a, b;
    map<pair<long long, long long>, long long> mp;

    for (int i = 0; i < n; i++) {
        cin >> a >> b;

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a - j >= 1 && b - k >= 1 &&
                    a - j + 2 <= h && b - k + 2 <= w) {
                    mp[make_pair(a - j, b - k)]++;
                }
            }
        }
    }

    long long ans[10];

    for (int i = 0; i < 10; i++) {
        if (i == 0) {
            ans[i] = (h-2) * (w-2);
        } else {
            ans[i] = 0;
        }
    }

    for (auto e: mp) {
        ans[0]--;
        ans[e.second]++;
    }

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}


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

int getMax(int k, const vector<int>& c)
{
  int ret = 0;
  for (int i = 0; i <= (int)c.size()-k; ++i) {
    int p = 1;
    for (int j = 0; j < k; ++j)
      p *= c[i+j];
    ret = max(ret, p);
  }
  return ret;
}

int main()
{
  int n, k;
  while (cin >> n >> k) {
    if ((n|k) == 0)
      break;

    vector<int> c(n);
    for (int i = 0; i < n; ++i)
      cin >> c[i];

    int t = getMax(k, c), s = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i+1; j < n; ++j) {
	swap(c[i], c[j]);
	s = max(s, getMax(k, c));
	swap(c[j], c[i]);
      }
    }

    if (t > s)
      cout << "NO GAME" << endl;
    else
      cout << s - t << endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int li=1,ls=n,ans=-1;
  while(li<=ls){
    int k=(li+ls)>>1;
    int c[2]={0,0};
    for(int i=n-k;i<=k-1;i++){
      c[s[i]-'0']=1;
    }
    if(c[0]+c[1]<=1){
      li=k+1;
      ans=k;
    }
    else ls=k-1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	auto s = readln.chomp;
	auto k = read.to!int;
	
	bool[string] xset;
	for(int i = 0; i < s.length; i ++){
		for(int j = i + 1; j < i + 10 && j <= s.length; j ++){
			xset[s[i .. j]] = 1;
			}
		}
	
	string[] xs = xset.keys;
	xs.sort();
	
	debug xs.writeln;
	
	xs[k - 1].writeln;
	
	}

Measured memory_bytes: 5372