akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        long a = s.nextLong(),b=s.nextLong(),c=s.nextLong(),k=s.nextLong();
        long sum = 0;
        long v = Math.min(a,k);
        sum+= v;
        a-=v;k-=v;
        v = Math.min(b,k);
        b-=v;k-=v;
        v = Math.min(c,k);
        sum+=(-1*v) ;
        c-=v;k-=v;
        System.out.println(sum);


    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25392
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
using namespace std;
string cell[100];
int n,m;
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++)
    cin>>cell[i];
  int r = 0;
  int c = 0;
  while(r<n){
    while(c<m){
      if(cell[r][c]=='#'){
        cell[r][c] = '.';
        if(c<m && cell[r][c+1]=='#') c++;
        else if(c==m-1) c= m-1;
        else break;
      }
      else break;
    }
    r++;
  }
  int cnt = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      //cout<<cell[i][j]<<" ";
      if(cell[i][j]=='#') cnt++;
    }
    //cout<<endl;
  }
  if(cnt>0) cout<<"Impossible"<<endl;
  else cout<<"Possible"<<endl;
  return 0;
}


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

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

  int n,k; cin >> n >> k;
  string s; cin >> s;

  int ans = 0,l = 0,r = 0;
  int cnt = 0;
  queue<int> q;
  for(int i = 0; i < n; i++){
    if(s[i] == '0'){
      while(r < n && s[r] == '0'){
        r++;
      }
      q.push(r);
      cnt++;
      if(cnt > k){
        l = q.front(); q.pop();
        cnt--;
      }
      i = r-1;
    }
    else {
      r++;
    }
    ans = max(ans,r - l);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List

solve a b c
    | any even [a, b, c] = 0
    | otherwise =
        minimum [a * b, b * c, c * a]

main :: IO ()
main = do
    [a, b, c] <- fmap read . words <$> getLine :: IO [Int]
    print $ solve a b c

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t N,K;
    cin >> N >> K;

    N%=K;
    int64_t NN = abs(N - K);
    int64_t ans;
        
    if(N>NN){
        ans = NN;
    }else{
        ans = N;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    int k;
    scanf("%d",&k);
    char s[200];
    scanf("%s",s);

    if(strlen(s)<=k)
    {
        printf("%s\n",s);
    }
    else
    {
        char t[k+4];

        strncpy(t,s,k);
        t[k]=('.');
        t[k+1]=('.');
        t[k+2]=('.');
        t[k+3]=('\0');
        

        printf("%s\n",t);
    }
    
    return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
using namespace std;


int main(int argc, char *argv[])
{
    // VARIABLES
    int N, Q;
    vector<tuple<int, int, int>> L;
    set<tuple<int, int>> D;

    // INPUT
    cin >> N >> Q;
    for (int i=0; i<N; i++){
        int s,t,x;
        cin >> s >> t >> x;
        L.emplace_back(s-x, t-x, x);
    }

    for (int i=0; i<Q; i++){
        int d;
        cin >> d;
        D.insert(make_tuple(d, i));
    }
   

    // PROC
    sort(L.begin(), L.end(), [](const tuple<int, int, int>& left, const tuple<int, int, int>& right) {
        if (get<2>(left) != get<2>(right)) {
            return get<2>(left) <= get<2>(right);
        } else if ((get<0>(left) != get<0>(right))) {
            return get<0>(left) <= get<0>(right);
        } else {
            return get<1>(left) <= get<1>(right);
        }

    });

    vector<int> DD(Q, -1);
    for (auto l : L){
        int s, t, x;
        tie(s, t, x) = l;

        auto it = D.lower_bound(make_tuple(s, -1));
        while (it != D.end()) {
            int d = get<0>(*it);
            int idx = get<1>(*it);

            if (d >= t) {
                break;
            }

            DD[idx] = x;
            D.erase(it++);
        }
    }

    // OUTPUT
    for (auto d : DD) {
        cout << d << endl;
    }
    
    return 0;   
}

Measured memory_bytes: 14448
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int h, w;
    cin >> h >> w;
    string p="",a ="";
    rep(i, w + 2)p += "#";
    vector<string>pixel(h+2);
    rep(i, h + 2) {
        if (i == 0 || i == h + 1)pixel[i] = p;
        else {
            cin >> a;
            pixel[i] = "#" + a + "#";
        }
    }
    for (auto s : pixel)cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N, M =map(int,input().split())
L = []
for _ in range(N):
    L.append(list(map(int,input().split())))
L.sort()
ans = 0
for l in L:
    if M <= 0:
        break
    if M - l[1] > 0:
        ans += l[0] * l[1]
        M -= l[1]
    else:
        ans += (M * l[0])
        break
print(ans)

Measured memory_bytes: 27760
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int main(){
  int N,M;
  cin >> N >> M;
  int k[M];
  int s[11][11];
  int p[M];
  rep(i,M) {
	cin >> k[i];
	rep(j,k[i]) {
	  cin >> s[i][j];
	  s[i][j]--;
	}
  }
  rep(i,M) cin >> p[i];

  
  // rep(i,M) {
  // 	rep(j,k[i]) {
  // 	  cout << s[i][j];
  // 	}
  // 	cout << endl;
  // }

  

  //make bit pattern
  int ans = 0;
  for(int bit=0; bit < (1 << N); bit++) {
	vector<bool> isturn(10,false);

	rep(i,N) {
	  if((1<<i) & bit) {
		isturn[i] = true;
	  }
	}
	
	//	for(auto itr : isturn) cout << itr;
	//	cout << endl;


	int tmp = 0;
	rep(i,M) {
	  int cnt = 0;
	  rep(j,k[i]) {
		if(isturn[s[i][j]]) cnt++;
	  }
	  if(cnt%2 == p[i]) tmp++;
	}
	if(tmp == M) ans++;
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	vector<int> arr(101);
	for(int p; cin >> p;) arr[p]++;
	int most = *max_element(all(arr));
	rep(i, 101) {
		if(arr[i] == most)
			cout << i << endl;
	}
	return 0;
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int ans[] = new int[n];
		for(int i = 0; i < q;i++) {
			int a = sc.nextInt();
				ans[a-1]++;

		}
		for(int m = 0; m < n;m++) {
			if(k - (q - ans[m]) > 0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}

	}

}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

const int N = 2e5 + 10;

PII m[N];
LL diff[N];

bool cmp(PII a, PII b)
{
    return a.first < b.first;
}

int locate(LL x, int left, int right)
{
    int l = left, r = right;
    while (l < r) {
        int mid = l + r + 1 >> 1;
        if (m[mid].first <= x)
            l = mid;
        else
            r = mid - 1;
    }
    return l;
}

int main()
{
    int n, d, a;
    LL res = 0;
    scanf("%d%d%d", &n, &d, &a);
    for (int i = 1; i <= n; ++i) {
        int x, h;
        scanf("%d%d", &x, &h);
        m[i] = {x, h};
    }
    
    sort(m + 1, m + n + 1, cmp);
    
    for (int i = 1; i <= n; ++i) {
        diff[i] += diff[i - 1];
        m[i].second -= diff[i];
        if (m[i].second <= 0)
            continue;
        LL cnt = m[i].second / a;
        if (m[i].second % a)
            cnt++;
        res += cnt;
        LL k = (LL)m[i].first + d * 2;
        diff[i] += a * cnt;
        diff[locate(k, i, n) + 1] -= a * cnt;
    }
    
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 6776
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x, y;
        x = in.nextInt(); y = in.nextInt();
        if (y % 2 != 0) {
            System.out.println("No");
        } else {
            if (y >= 2 * x && y <= 4 * x) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 35792
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main()
{
auto ip = readln.split.to!(int[]);
writefln("%(%s %)", ip.sort().array);
}


Measured memory_bytes: 2516
package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}



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

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

    vector<ll> ans;
    ll p,q,r,s;
    p=a*c;
    q=a*d;
    r=b*c;
    s=b*d;
    ans.push_back(p);
    ans.push_back(q);
    ans.push_back(r);
    ans.push_back(s);

    sort(ans.begin(),ans.end(),greater<ll>());
    cout<<ans[0]<<endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int arr[N]; 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
	int pos=0;
	int ans=0;
	int sum=1;
	
	for(int i=1;i<=n;i++){
		if(arr[i]<=arr[i-1])  sum++;
		else {
//			cout<<sum<<endl;
			ans=max(sum,ans);
			sum=1;
		}
	}
	ans=max(sum,ans);
 	cout<<ans-1	<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> A(100100, 0);
    rep(i, n) {
        int a;
        cin >> a;
        if(a + 1 <= 100000) {
            A[a + 1]++;
        }
        A[a]++;
        if(a - 1 >= 0) {
            A[a - 1]++;
        }
    }
    int ans = 0;
    for(auto x : A) {
        ans = max(ans, x);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
n,m=map(int,input().split())
b=[]
for i in range(n):
    x= list(map(int, input().split()))
    b.append(x)
y=[]
for i in range(m):
    a=int(input())
    y.append(a)
for i in range(n):
    ans=0
    for j in range(m):
        ans+= b[i][j]*y[j]
    print(ans)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;

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

/*------------------------------------/
for library*/

constexpr double TL = 1.99;
constexpr ll CYCLES_PER_SEC = 2800000000;
struct Timer {
  ll start;
 
  Timer() { reset(); }
 
  void reset() { start = getCycle(); }
 
  inline double get() { return (double) (getCycle() - start) / CYCLES_PER_SEC; }
 
  inline ll getCycle() {
    unsigned low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((ll) low) | ((ll) high << 32);
  }
};

uint32_t XorShift(void) {
	static uint32_t x = 123456789;
	static uint32_t y = 362436069;
	static uint32_t z = 521288629;
	static uint32_t w = 88675123;
	uint32_t t;
 
	t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

double Prob(void){
	double ret = (double)XorShift() / UINT_MAX;
	return ret;
}

class Status{
public:
};
/*------------------------------------*/
int D = 365;
int c[30];
int s[400][30];
int t[400];
ll last[30];
void input(){
    cin >> D;
    rep(i,26)cin >> c[i];
    rep(d,D)rep(i,26)cin >> s[d][i];
    rep(d,D){
        cin >> t[d];
        t[d]--;
    }
}
ll calc(){
    ll score = 0;
    // 増える
    for(int d = 0; d < D; d++){
    }
    // 減る
    rep(i,26){
        last[i] = 0;
    }
    for(ll d = 0; d < D; d++){
        score += s[d][t[d]];
        for(int i = 0; i < 26; i++){
            if(t[d] == i)last[i] = d+1;
            score -= c[i] * ((d+1) - last[i]);
        }
        cout << score << endl;
    }
    return score;
}
void simulate(){
    /*
    Timer timer;
    timer.reset();
    while(1){
        auto now_time = timer.get();
        if(now_time >= TL) break;
        auto rest_time = TL - now_time;
    }*/
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    input();
    //simulate();
    calc();
}


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

int main() {
 int X, N, Z;
 X = 0; 
 cin >> N;
 Z = N; 
  for(int i = 0; i < 9; i++){
  X += N % 10;
  N = N / 10;
  }
  if((Z % X) != 0){
  cout << "No" << endl;
  }else{
  cout << "Yes" << endl;
  }
}

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

int main() {
    int a[3];
    for(int i=0; i<3; i++) cin >> a[i];

    int res = 1000;
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            for(int k=0; k<3; k++) {
                int t = abs(a[i]-a[j])+abs(a[j]-a[k]);
                if(i!=j && j!=k && k!=i) res = min(res, t);
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*
T(i, V) 前 i 个物品，获得 V 的价值所需最小容量
T(i, V) = min{T(i, V+1), T(i-1, V), T(i-1, V - v_i) + w_i }
*/

package main

import "fmt"
import "math"

const N = 105
const V = 1e3 * N + 5
var T [V]int
var vs, ws [N]int

func umin(current *int, val int) {
  if val < *current {
    *current = val
  }
}

func zeroOnePack(T []int, w, v int, totalW int, maxV int) {
  for i := maxV; i >= 0; i-- {
    umin(&T[i], T[i+1])
    if i - v >= 0 && T[i-v] <= totalW && T[i-v] + w <= totalW {
      umin(&T[i], T[i-v] + w)
    }
  }
}

func main() {
  var n, w int
  fmt.Scanf("%d %d", &n, &w)
  sumV := 0
  for i := 0; i < n; i++ {
    fmt.Scanf("%d %d", &ws[i], &vs[i])
    sumV += vs[i]
  }
  for i := 1; i <= sumV+1; i++ {
    T[i] = math.MaxInt32
  }
  T[0] = 0
  for i := 0; i < n; i++ {
    zeroOnePack(T[:sumV+2], ws[i], vs[i], w, sumV)
  }
  
  var maxV int
  for i := sumV; i >= 0; i-- {
    if T[i] < math.MaxInt32 {
      maxV = i
      break
    }
  }
  fmt.Println(maxV)
}



Measured memory_bytes: 2644
import java.util.*;

class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);


	int[][] h = new int[100][51];
	for(int i=0; i<100; i++) Arrays.fill(h[i], -1);
	int n = 0;
	while(sc.hasNext()){
	    String[] line = sc.next().split(",");
	    for(int i=0; i<line.length; i++){
		h[n][i] = Integer.parseInt(line[i]);
	    }
	    n++;
	}

	for(int i=1; i<n; i++){
	    if(i<=n/2){
		for(int j=0; j<n; j++){
		    if(h[i][j]==-1) break;
		    int num = h[i][j];
		    h[i][j] = Math.max(h[i][j], h[i-1][j]+num);
		    if(j!=0) h[i][j] = Math.max(h[i][j], h[i-1][j-1]+num);
		}
	    }else{
		for(int j=0; j<n; j++){
		    if(h[i][j]==-1) break;
		    int num = h[i][j];
		    h[i][j] = Math.max(h[i][j], h[i-1][j]+num);
		    if(h[i-1][j+1]!=-1) h[i][j] = Math.max(h[i][j], h[i-1][j+1]+num);
		}
	    }
	}

	System.out.println(h[n-1][0]);
    }

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

Measured memory_bytes: 20768
n, k, c = map(int, input().split())
s = list(input())
os = 0
for ss in s:
    if ss == 'o':
        os += 1
s2 = list(reversed(s))

if c == 0 and os > k:
    exit(0)

def calc(s):
    global n, k, c
    answer = set()
    pre = None
    for idx, i in enumerate(s):
        if i == 'o' and (pre is None or idx > pre + c):
            answer.add(idx + 1)
            # 前回働いた日を記録
            pre = idx
        if len(answer) >= k:
            return answer

answer1 = calc(s)
answer2 = calc(s2)
answer2 = set(map(lambda x: len(s2) - x + 1, answer2))

for i in sorted(list(answer1 & answer2)):
    print(i)


Measured memory_bytes: 56560
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
ans += sum(b)
for i in range(n-1):
  if a[i+1]-a[i] == 1:
    ans += c[a[i]-1]
print(ans)

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

int main(){
  string n;
  cin >> n;
  string ans = "No";
  if(n[0] == '7' || n[1] == '7' || n[2] == '7') ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

M, = map(int, sys.stdin.readline().rstrip().split(" "))
total_sum = 0
total_digits = 0
for _ in range(M):
    d, c = map(int, sys.stdin.readline().rstrip().split(" "))
    total_digits += c
    total_sum += d*c
answer = ((total_sum-1) // 9) + total_digits -1
print(answer)
exit(0)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int x; cin >> x;
    if(x>=30) pr("Yes");
    else pr("No");
    return 0;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    vector<int> A(3);
    int five = 0;
    int seven = 0;
    REP(i,3)cin >> A[i];
    REP(i,3){
        if(A[i]==5){
            five ++;
        }
        if(A[i]==7){
            seven ++;
        }
    }
    if(five==2&&seven==1)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
cntp = 0
cntq = 0
ALL = list(itertools.permutations(range(1, N+1), N))

for i in range(len(ALL)):
    if ALL[i]==P:
        break
    elif ALL[i]!=P:
        cntp += 1
for i in range(len(ALL)):
    if ALL[i]==Q:
        break
    elif ALL[i]!=Q:
        cntq += 1

print(abs(cntq-cntp))

Measured memory_bytes: 8052
#include<stdio.h>
int main(void){
	int i,j,k,a[200],n[3][200],x,y;
	scanf("%d",&x);
	for(i=0;i<x;i++){
		a[i]=0;
		scanf("%d%d%d",&n[0][i],&n[1][i],&n[2][i]);
	}
	for(i=0;i<3;i++){
		for(j=0;j<x;j++){
			y=n[i][j];
			for(k=0;k<x;k++){
				if(j!=k && n[i][j]==n[i][k]){
					y=0;
					break;
				}
			}
			a[j]+=y;
		}
	}
	for(i=0;i<x;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    ll ok = 10000000000;
    ll ng = 0;
    while(ok!=ng+1) {
        ll mid = (ok+ng)/2;
        tmp = 0;
        for(int i=0;i<N;i++) {
            ll num = A[i]/mid;
            if(A[i]%mid==0) num--;
            tmp += num;
        }
        if(tmp<=K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 5336
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        int[][] hw = new int[h][w];
        int idx = 1;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                while (a[idx] == 0) {
                    idx++;
                }
                hw[i][j] = idx;
                a[idx]--;
            }
        }

        for (int i = 0; i < h; i++) {
            StringJoiner sj = new StringJoiner(" ");
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    sj.add(String.valueOf(hw[i][j]));
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    sj.add(String.valueOf(hw[i][j]));
                }
            }
            System.out.println(sj);
        }
    }

}


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

ans = 0
for i in range(A,B+1,1):
    tmp = list(str(i))
    is_kai = True
    for j in range(0,len(tmp),1):
        if tmp[j]!=tmp[len(tmp)-1-j]:
            is_kai=False
            break
    if is_kai:
        ans+=1

print(ans)

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

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

    ll n, k;
    cin >> n >> k;

    map<ll, ll> mp;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll res = 0;
    rep1(i, 100001){
        res += mp[i];
        if(res >= k){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        for(int i=0; i<k; i++) {
            int[] increase = new int[n];
            int[] decrease = new int[n];
            for(int j=0; j<n; j++) {
                int left = Math.max(0, j-a[j]);
                increase[left]++;
                int right = j+a[j];
                if(right<n) {
                    decrease[right]++;
                }
            }
            a[0] = increase[0];
            boolean isAllN = true;
            for(int j=1; j<n; j++) {
                a[j] = a[j-1] - decrease[j-1] + increase[j];
                if(isAllN && a[j]!=n) {
                    isAllN = false;
                }
            }
            if(isAllN) {
                break;
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; i++) {
            sb.append(a[i]);
            if(i<n-1) {
                sb.append(' ');
            }
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 62860
k = int(input())

a = list(range(1,10))

while True:
    if(k<=len(a)):
        print(a[k-1])
        exit()
    k-=len(a)
    old = a
    a = []
    for x in old:
        for i in range(-1,2):
            d = x%10+i
            if d<0 or d>9:
                continue
            nx = x*10+d
            a.append(nx)


Measured memory_bytes: 11028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

#define MAX_NCK 201010
ll f[MAX_NCK], rf[MAX_NCK];

// (a/b)%P の場合は，(a%P)*modinv(b)%P とする
ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

bool isinit = false;

void init() {
    f[0] = 1;
    rf[0] = modinv(1);
    for(int i = 1; i < MAX_NCK; i++) {
        f[i] = (f[i - 1] * i) % MOD;
        rf[i] = modinv(f[i]);
    }
}

ll nCk(ll n, ll k) {
    if(!isinit) {
        init();
        isinit = 1;
    }
    ll nl = f[n]; // n!
    ll nkl = rf[n - k]; // (n-k)!
    ll kl = rf[k]; // k!
    ll nkk = (nkl * kl) % MOD;

    return (nl * nkk) % MOD;
}
ll calc(ll x1, ll y1, ll x2, ll y2){
    ll tate=abs(y2-y1);
    ll yoko=abs(x2-x1);
    return nCk(tate+yoko,min(yoko,tate))%MOD;
}

int main(void) {
    
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<pair<ll,ll>> v;
    ll y=h-a-1;
    ll x=b;
    while(y>=0&&x<w){
        v.pb(mp(x,y));
        x++;y--;
    }
    ll ans=0;
    rep(i,v.size()){
        ans+=calc(0,0,v[i].first, v[i].second)*calc(v[i].first, v[i].second,w-1,h-1)%MOD;
        ans%=MOD;
    }
    fin(ans);
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long int n,m;
    cin>>n>>m;
    if(n==1 || m==1)
    	cout<<1;
    else
    	cout<<((n*m+1)/2);

}
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<pair<ll,int>> a(n); 
  mint sum = 1;
  bool flag = false;
  rep(i,n){
    cin >> a[i].F;
    sum *= a[i].F;
    if(a[i].F>=0){
      a[i].S = 0;
      flag = true;
    } else {
      a[i].F *= -1;
      a[i].S = 1;
    }
  }
  if(k==n){
    cout << sum.x << ln; return 0;
  }
  if(k%2 && !flag){
    sort(a.begin(),a.end());
    mint ans = 1;
    rep(i,k){
      ans *= (-1)*a[i].F;
    }
    cout << ans.x << ln; return 0;
  }

  sort(a.rbegin(),a.rend());
  mint ans = 1;
  int cnt = 0;
  rep(i,k){
    ans *= a[i].F;
    cnt += a[i].S;
  }

  if(cnt%2==0 || ans.x==0){
    cout << ans.x << ln; return 0;
  }
  ll A=inf,B=inf,C=inf,D=inf;
  REP(i,k,n){ if(a[i].S==0){ C = a[i].F; break; } }
  REP(i,k,n){ if(a[i].S==1){ D = a[i].F; break; } }
  for(int i=k-1; i>=0; i--){ if(a[i].S==0){ B = a[i].F; break; } }
  for(int i=k-1; i>=0; i--){ if(a[i].S==1){ A = a[i].F; break; } }
  if((C==inf || A== inf)&& (B!=inf && D!= inf)){
    ans *= D;
    ans /= B;
  }
  if((B==inf || D== inf) && (A!=inf && C!= inf)){
    ans *= C;
    ans /= A;
  }
  if(B!=inf && D!= inf && A!=inf && C!= inf){
    if(C*B >= A*D ){
      ans *= C;
      ans /= A;
    }
    if(C*B < A*D ){
      ans *= D;
      ans /= B;
    }
  }
  cout << ans.x << ln;
  return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
 
#define FORu(i, start, n) for (ll i = start; i < (ll)(n); i++)
#define FORd(i, start, n) for (ll i = start; i > (ll)(n); i--)
#define FORa(vec) for (auto x : vec) cout << x << " ";
#define pb push_back
#define pf pop_front
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
 
//==============================================================================
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,d; cin >> n >> d;
    d *= d;
    int ctr = 0;
    FORu(i, 0, n){
      ll p,q; cin >> p >> q;
      ll dist = (p*p)+(q*q);
      if(dist <= d) ctr++;
    }
    cout << ctr << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(1);
    solve();  	
}

void solve() {
	int n, q;
	cin >> n >> q;
	vector<pair<double, double>> dt(n);
	vector<double> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> dt[i].x >> dt[i].y >> x[i];
		dt[i].x -= 0.5; dt[i].y -= 0.5;
	}
	set<pair<double, double>> d;
	for (int i = 0; i < q; ++i) {
		int num;
		cin >> num;
		d.insert({num, (double)i});
	}

	vector<vector<double>> sg(n);
	for (int i = 0; i < n; ++i) {
		dt[i].x -= x[i];
		dt[i].y -= x[i];
		sg[i] = {x[i], dt[i].x, dt[i].y};
	}
	sort(sg.begin(), sg.end());

	/*for (auto it : sg) {
		cout << it[0] << " " << it[1] << " " << it[2] << endl;
	}*/

	vector<int> ans(q, -1);
	for (auto it : sg) {
		double cur = it[0], l = it[1], r = it[2];
		while (!d.empty()) {
			auto it = d.lower_bound({l, 0});
			if (it == d.end()) {
				break;
			}
			int curx = it->x, curid = it->y;
			if (curx <= r) {
				ans[curid] = cur;
				d.erase(it);
			}
			else {
				break;
			}
		}
	}

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

Measured memory_bytes: 45696
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		for(int i=0;i<a;i++)scanf("%d",d+i);
		int now=0;
		int p=1;
		for(int i=0;i<b-1;i++){
			p*=d[i];
		}
		for(int i=b-1;i<a;i++){
			p*=d[i];
			now=max(now,p);
			p/=d[i-b+1];
		}
		int S=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				int c=d[i];
				d[i]=d[j];
				d[j]=c;
				p=1;
		for(int k=0;k<b-1;k++){
			p*=d[k];
		}
		for(int k=b-1;k<a;k++){
			p*=d[k];
			S=max(S,p);
			p/=d[k-b+1];
		}
				c=d[i];
				d[i]=d[j];
				d[j]=c;
			}
		}
		if(S>=now)printf("%d\n",S-now);
		else printf("NO GAME\n");
	}
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int a,b,c,x;
	cin >> a >> b >> c >> x;

	ll ans = 0;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(500*i + 100 * j + 50 * k == x) ans++;
			}
		}
	}
	cout <<ans << endl;
	//タイピングうまくいかない死にたい

}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = 1e5+1;
int N, H[MAXN];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> H[i];
    }
    if(N==1)
    {
        cout << "Yes";
        return 0;
    }
    int min_val = H[N-1];
    for(int i=N-1; i>0; i--)
    {
        if(H[i] > min_val+1)
        {
            cout << "No";
            return 0;
        }
        min_val = min(min_val, H[i]);
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	string s;
	cin>>s;
	int c[3] = {};
	for(auto &i : s)
		c[i-'a']++;
	int mn = 1e9, mx = -1;
	for(int i = 0; i < 3; i++)
	{
		mn = mn > c[i] ? c[i] : mn;
		mx = mx < c[i] ? c[i] : mx;
	}
	cout<<(mx - mn < 2 ? "YES" : "NO")<<'\n';
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner scanner = new Scanner(System.in);

    String sa = scanner.next();
    String sb = scanner.next();
    String sc = scanner.next();

    scanner.close();

    String[] SA = sa.split("");
    String[] SB = sb.split("");
    String[] SC = sc.split("");

    int currentSA = 0;
    int currentSB = 0;
    int currentSC = 0;

    // a:Aの番、b:Bの番、c:Cの番
    String turn = "a";

    String winner = "";

    while (winner.equals("")) {
      if (turn.equals("a")) {
        if (currentSA == SA.length){
          winner = "A";
        } else {
          turn = SA[currentSA];
          currentSA++;
        }
      } else if(turn.equals("b")) {
        if (currentSB == SB.length){
          winner = "B";
        } else {
          turn = SB[currentSB];
          currentSB++;
        }
      } else {
        if (currentSC == SC.length){
          winner = "C";
        } else {
          turn = SC[currentSC];
          currentSC++;
        }
      }
    }

    System.out.println(winner);

  }

}

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

bool is_squere(int N)
{
	int r = (int)floor(sqrt((long double)N));
	return (r * r) == N;
}
int main()
{
	int a, b, c;
	cin >> a >> b;
	if (b < 10)
	{
		c = a * 10 + b;
	}
	else if (b == 100)
	{
		c = a * 1000 + b;
	}
	else
	{
		c = a * 100 + b;
	}
	if (is_squere(c))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return (0);
}


Measured memory_bytes: 3684
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let x1 = get!();
    let y1 = get!();
    let x2 = get!();
    let y2 = get!();
    
    let x3 = x2 + (y1 - y2);
    let y3 = y2 + (x2 - x1);
    let x4 = x3 + (x1 - x2);
    let y4 = y3 + (y1 - y2);
    
    println!("{} {} {} {}", x3, y3, x4, y4);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}
long long mod=1000000007;

int main(void){
    int n,ans;
    scanf("%d",&n);
    ans=111*((n+110)/111);
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
(* O(N * log(N)) (N = |xs|) *)
(* unique : ('a -> 'a -> int) -> 'a list -> 'a list = <fun> *)
let unique (type u) (cmp : u -> u -> int) =
  let module S = Set.Make(struct type t = u let compare = cmp end) in
  fun xs -> S.elements (List.fold_right S.add xs S.empty)

(* O(n * log(n)) *)
let solve n ds = unique compare ds |> List.length

let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

let read_ints n =
  fold_int
    (fun sofar _ -> read_int () :: sofar)
    []
    n |> List.rev

let _ =
  let n = read_int () in
  let ds = read_ints n in
  solve n ds |> string_of_int |> print_endline

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

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

int N;
int p[SIZE];
ll K;

int main()
{
	cin >> N;
	int cnt=0;
	rep(i,1,N+1){
		cin >> p[i];
		if(i==1)continue;
		if(p[i]==i && p[i-1] == i-1){
			swap(p[i],p[i-1]);
			cnt++;
		}
	}
	if(p[1]==1){
		swap(p[1],p[2]);
		cnt++;
	}
	rep(i,2,N+1){
		if(p[i] == i){
			swap(p[i],p[i-1]);
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
    int N; cin >> N;
    int r = 0, g = 0, b = 0;
    
    long long const MOD = 1000000007;
    long long ans = 1;
    for(int i=0; i<N; ++i) {
        int A; cin >> A;
        int cnt = (r == A) + (g == A) + (b == A);
        ans = ans * cnt % MOD;
        if(r == A) ++r;
        else if(g == A) ++g;
        else if(b == A) ++b;
    }
    cout << ans << endl;
}

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

int main() {
	
	long long K,X,D, aux;

	scanf("%lld %lld %lld", &X, &K, &D);

	X = abs(X);

	aux = X/D;

	if (aux > K) {
		X -= D*K;
	}else{
		X -= D*aux;K -= aux;

		if (K%2==1) {
			X -= D;X = abs(X);
		}

	}

	printf("%lld\n", X);

	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define INF (1 << 29)

struct edge { int to, cost; };
typedef pair<int, int> P;   // firstは最短距離、secondは頂点の番号

const int MAX_V=1000000;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

int dijkstra(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();

        int v=p.second;
        if(d[v] < p.first) continue;
        for(int i=0; i<G[v].size(); i++){
            edge e=G[v][i];
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    return d[V-1];
}

int main(){
    int E;
    int from, to;
    cin >> V >> E;
    for(int i=0; i<E; i++){
        cin >> from >> to;
        G[from-1].push_back(edge{to-1,1});
        G[to-1].push_back(edge{from-1,1});
    }
    
    if(dijkstra(0)==2)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, inf = 0x3f3f3f3f;

vector<int> g[3 * maxn];
int d[3 * maxn];

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

    int n, m;
    cin >> n >> m;
    while (m--){
        int u, v;
        cin >> u >> v;
        //模3循环，点分成3层，模3为0的u连到模3为1的v，后面同理
        g[3 * u].push_back(3 * v + 1);
        g[3 * u + 1].push_back(3 * v + 2);
        g[3 * u + 2].push_back(3 * v);
    }

    int s, t;
    cin >> s >> t;

    queue<int> qi;
    qi.push(3 * s);
    while (!qi.empty()){
        int u = qi.front(); qi.pop();
        for (int v : g[u]) if (!d[v]) {
            d[v] = d[u] + 1;
            qi.push(v);
        }
    }

    cout << (d[3 * t] ? d[3 * t] / 3 : -1) << endl;
    return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
    return 0;
}


Measured memory_bytes: 3596