akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int w, h;
	int dx[4] = { -1,0,1,0 };
	int dy[4] = { 0,-1,0,1 };
	char input;
	while (1) {
		pair<int, int> start;
		cin >> w >> h;
		if (w == 0) break;
		vector<vector<int>> field(h + 2, vector<int>(w + 2, 1));
		for (int i = 1; i < h + 1; i++) {
			for (int j = 1; j < w + 1; j++) {
				cin >> input;
				if (input == '.') {
					field[i][j] = 0;
				}
				else if (input == '@') {
					start.first = i;
					start.second = j;
					field[i][j] = 0;
				}
			}
		}
		/*
		rep(i, h + 2) {
			rep(j, w + 2) {
				cout << field[i][j] << " " ;
			}
			cout << endl;
		}
		*/

		queue<pair<int, int>> que;
		int ans = 0;
		que.emplace(start.first, start.second);
		while (!que.empty()) {
			pair<int, int> now = que.front();
			que.pop();
			if (field[now.first][now.second] == 1) continue;
			ans++;
			field[now.first][now.second] = 1;
			rep(k, 4) {
				//cout << now.first + dy[k] << " " << now.second + dx[k] << endl;
				//cout << field[now.first + dy[k]][now.second + dx[k]] << endl;
				
				if (field[now.first + dy[k]][now.second + dx[k]] == 0) {
					que.emplace(now.first + dy[k], now.second + dx[k]);
				}
				
			}
		}
		
		cout << ans << endl;
	}
}



Measured memory_bytes: 3124
mod = 998244353
rng = 2500100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def inv(x):
  return pow(x,mod-2,mod)
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*inv(fctr[n-k])*inv(fctr[k])%mod

n,m = map(int,input().split())
ans = cmb(n+3*m-1,n-1)
ans = (ans-n*cmb(n+m-2,n-1))%mod
if n>m+1:
  for i in range(m+1,min(3*m,n)+1):
    if (3*m-i)%2 == 1:
      continue
    x = (3*m-i)//2
    ans = (ans-cmb(n,i)*cmb(x+n-1,n-1))%mod
print(ans)

Measured memory_bytes: 107272
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  int red,green,blue;
  int k;
  cin >> red >> green >> blue;
  cin >>k;
  for(int i=0;i<k;i++){
    if(blue>=red&&red>=green){
      green=green*2;
    }else{
      blue=blue*2;
    }
  }
  if(red<green&&green<blue){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int d, n;
  cin >> d >> n;
  int ans;
  if(n == 100) {
    ans = n * pow(100, d) + pow(100, d);
  } else {
    ans = n * pow(100, d);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

n,x,y=map(int,input().split())
x-=1
y-=1
res=[0]*n
for i in range(n):
  for j in range(i+1,n):
    m = min(j-i, abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)
    res[m]+=1
for i in range(1,n):
  print(res[i])

Measured memory_bytes: 3444
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int a, b, c, x, cnt;
	cin >> a >> b >> c >> x;
	cnt = 0;
	lp(a + 1)
		lop(b + 1, j)
			lop(c + 1, k)
				if (i * 500 + j * 100 + k * 50 == x)cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
int const INF=1000000000;
int DP[100001];
vector<int>H(100000);
int rec(int n,int k){
    if(n==0)return 0;
    if(DP[n]!=INF)return DP[n];

    int res=INF;
    for(int i=1;i<=k;i++){
        if(n-i>=0)res=min(res,rec(n-i,k)+abs(H[n-i]-H[n]));
    }
    return DP[n]=res;
}
typedef long long ll;
int main(){
    int N,K;
    cin>>N>>K;
    for(int i=0;i<=100001;i++){
        DP[i]=INF;
    }
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    cout<<rec(N-1,K)<<endl;
}

Measured memory_bytes: 8832
N = int(input())

if N <= 9:
  print(N)
elif N <= 99:
  print(9)
elif N <= 999:
  print(9+(N-99))
elif N <= 9999:
  print(909)
elif N <= 99999:
  print(909+(N-9999))
elif N == 100000:
  print(90909)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.length();
    deque<char> dq;
    REP(i,n) {
        dq.push_back(s[i]);
    }
    int ans = 0;
    while (!dq.empty()) {
        if (dq.size() == 1) break;
        char f = dq.front();
        char b = dq.back();
        if (f == b) {
            dq.pop_front();
            if (dq.empty()) break;
            dq.pop_back();
        }
        else {
            if (f == 'x') {
                dq.push_back('x');
                ans++;
            }
            else if (b == 'x') {
                dq.push_front('x');
                ans++;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int x; cin>>x;
    if(x==3||x==5||x==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int main() {
  int A,B,C,D,a,b;
  
  cin >> A >> B >> C >> D;
  a = A + B;
  b = C + D;
  
  if(a == b){
    cout << "Balanced" << endl;
  }
  else if(a > b){
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
p [(h,w=gets.split.map &:to_i),[w,h]].map{|t,u|(1..t).map{|i|[[u,i],[i,u]].map{|x,y|a=[x/2*y,(x+1)/2*y,u*(t-i)];a.max-a.min}}}.flatten.min

Measured memory_bytes: 19324
import numpy as np
mod = (10**9)+7
def modpow(x, n):
  ans = 1
  mod = (10**9)+7
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x
      ans %= mod
    x = x*x
    x %= mod
    n = n >> 1 #ビットシフト
  return ans


def nCr(n,r):
    mod = (10**9)+7
    r = min(n,r)
    bunsi = bunbo = 1
    for i in range(1,r+1):
      bunsi = (bunsi * (n+1-i) )% mod
      bunbo = bunbo * i % mod
    ans = (bunsi * pow(bunbo,mod-2,mod)) % mod
    return ans

n,a,b = map(int,input().split())
print((modpow(2,n)- 1 - nCr(n,a) - nCr(n,b) )% mod)


Measured memory_bytes: 12796
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int table[3][3];



int main(){

	for(int row = 0; row < 3; row++){
		for(int col = 0; col < 3; col++){

			scanf("%d",&table[row][col]);
		}
	}

	scanf("%d",&N);

	int tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);

		for(int row = 0; row < 3; row++){
			for(int col = 0; col < 3; col++){

				if(table[row][col] == tmp){

					table[row][col] = 0;
				}
			}
		}
	}


	for(int row = 0; row < 3; row++){
		if(table[row][0] == 0 && table[row][1] == 0 && table[row][2] == 0){

			printf("Yes\n");
			return 0;
		}
	}

	for(int col = 0; col < 3; col++){
		if(table[0][col] == 0 && table[1][col] == 0 && table[2][col] == 0){

			printf("Yes\n");
			return 0;
		}
	}

	if(table[0][0] == 0 && table[1][1] == 0 && table[2][2] == 0){

		printf("Yes\n");
		return 0;
	}

	if(table[0][2] == 0 && table[1][1] == 0 && table[2][0] == 0){

		printf("Yes\n");
		return 0;
	}

	printf("No\n");

	return 0;
}


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

namespace ALDS1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; i++)
            {
                CommonLine commonLine = new CommonLine(Console.ReadLine().Select(c => c).ToArray(), Console.ReadLine().Select(c => c).ToArray());
                Console.WriteLine(commonLine.GetCommonLineLength(0, 0));
            }
            //Console.ReadLine();
        }
    }

    class CommonLine
    {
        char[] X;
        char[] Y;
        int[,] commonLineLength;

        public CommonLine(char[] X, char[] Y)
        {
            this.X = X;
            this.Y = Y;
            this.commonLineLength = new int[this.X.Length, this.Y.Length];
            for (int i = 0; i < this.X.Length; i++)
            {
                for (int j = 0; j < this.Y.Length; j++)
                {
                    this.commonLineLength[i, j] = -1;
                }
            }
        }

        public int GetCommonLineLength(int indexX, int indexY)
        {
            if (indexX >= X.Length || indexY >= Y.Length)
            {
                return 0;
            }

            if (this.commonLineLength[indexX, indexY] >= 0)
            {
                return this.commonLineLength[indexX, indexY];
            }

            if (this.X[indexX] == this.Y[indexY])
            {
                this.commonLineLength[indexX, indexY] = this.GetCommonLineLength(indexX + 1, indexY + 1) + 1;
                return this.commonLineLength[indexX, indexY];
            }

            if (indexX + 1 < this.X.Length && this.commonLineLength[indexX + 1, indexY] < 0)
            {
                this.commonLineLength[indexX + 1, indexY] = this.GetCommonLineLength(indexX + 1, indexY);
            }

            if (indexY + 1 < this.Y.Length && this.commonLineLength[indexX, indexY + 1] < 0)
            {
                this.commonLineLength[indexX, indexY + 1] = this.GetCommonLineLength(indexX, indexY + 1);
            }

            this.commonLineLength[indexX, indexY] = Math.Max(this.GetCommonLineLength(indexX + 1, indexY), this.GetCommonLineLength(indexX, indexY + 1));

            return this.commonLineLength[indexX, indexY];
        }
    }
}



Measured memory_bytes: 39264
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.size();
    int ans = 0;
    REP(i,n){
        if(i%2==0){
            if(s[i]=='p'){
                ans--;
            }
        }else{
            if(s[i]=='g'){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int ai[100005];
int fun(int i,int j)
{
    int sum=1;
    for(int q=1;q<=j;q++){
        sum*=i;
    }
    return sum;
}
int main()
{
	int a,b,c,d;
	scanf("%d",&a);
	int max1 = 1;
	for(int i=1;i<1000;i++)
	{
	    for(int j=2;j<50;j++)
        {
            int z = fun(i,j);
            if(z<=a && z>max1)
                max1=z;
        }
	}
    printf("%d\n",max1);
	return 0;
}
 

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

using namespace std;

int main()
{
    int i,p=0,q=0;
    long long k,sum=0,sum1=0;
    string s;
    cin>>s>>k;
    for(i=1; i<s.length(); i++)
        if(s[i]!=s[i-1])
            q=1;
    if(q==0)
    {
        sum=(k*s.length())/2;
    }
    else
    {
        for(i=1; i<s.length(); i++)
            if(s[i-1]==s[i])
            {
                sum++;
                i++;
            }
        if(k>1)
        {
            s+=s;
            for(i=1; i<s.length(); i++)
            {
                if(s[i-1]==s[i])
                {
                    sum1++;
                    i++;
                }
            }
            sum1=sum1-sum;
            sum=sum+sum1*(k-1);
        }
    }
    cout <<sum<< endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        Map<Character, List<Integer>> si = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            List<Integer> list = si.get(c);
            if (list == null) {
                list = new ArrayList<>();
                si.put(c,list);
            }
            list.add(i+1);
        }

        boolean found = true;
        int unit = 0;
        long ans = 0;
        int now = 0;
        for (int i = 0; i < t.length(); i++) {
            char c = t.charAt(i);
            if (!si.containsKey(c)) {
                found = false;
                break;
            }
            List<Integer> list = si.get(c);
            if (list.get(list.size()-1) <= now) {
                unit++;
                now = list.get(0);
            } else {
                now = find(list, now+1);
            }
            ans = (long)unit*s.length()+now;
        }

        System.out.println(found ? ans : -1);
    }

    private static int find(List<Integer> list, int key) {

        int ng = -1;
        int ok = list.size()-1;

        while (ng+1 < ok) {
            int mid = (ok+ng)/2;
            if (list.get(mid) >= key) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        return list.get(ok);
    }
}


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

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    string N;
    cin >> N;
    if(N[0] == '9' || N[1] == '9')
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';

}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    P = tuple(map(int,input().split()))

    A = [2*N*(i + 1) for i in range(N)]
    B = A[::-1]
    cnt = 1
    for a,b in zip(P[:-1],P[1:]):
        if a < b:
            A[b - 1] += cnt
        else:
            B[b - 1] += cnt
        cnt += 1
    print(' '.join(map(str,A)))
    print(' '.join(map(str,B)))

if __name__ == '__main__':
    main()

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

using usize = size_t;
using u64 = uint64_t;

usize n;
u64 m;
std::vector<std::tuple<usize, usize, u64, u64>> QS;
std::vector<u64> SQ;

u64 dfs();
int main() {
  usize q;
  std::cin >> n >> m >> q;
  QS.resize(q);
  for (usize i = 0; i < q; i++) {
    usize a, b;
    u64 c, d;
    std::cin >> a >> b >> c >> d;
    QS[i] = std::make_tuple(a - 1, b - 1, c, d);
  }
  std::cout << dfs() << '\n';
}

u64 dfs() {
  u64 res = 0;
  if (SQ.size() == n) {
    for (auto q : QS) {
      usize a, b;
      u64 c, d;
      std::tie(a, b, c, d) = q;
      if (SQ[b] - SQ[a] == c) res += d;
    }
    return res;
  }
  u64 last = SQ.empty() ? 1 : SQ[SQ.size() - 1];
  for (u64 x = last; x <= m; x++) {
    SQ.push_back(x);
    res = std::max(res, dfs());
    SQ.pop_back();
  }
  return res;
}

Measured memory_bytes: 3640
# coding: utf-8

H, W = map(int, input().split(" "))

S = []
for i in range(H):
    tmp = input()
    S.append(list(tmp))


def eight_math_index(i, j, H, W):
    result = [(i-1, j),
              (i, j - 1),  (i, j + 1),
              (i + 1, j)]
    return list(filter(lambda x: (0 <= x[0] <= (H-1)) and (0 <= x[1] <= (W-1)), result))


for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            eight = eight_math_index(i, j, H, W)
            shuui_kuro_kazu = 0
            for (k, l) in eight:
                if S[k][l] == "#":
                    shuui_kuro_kazu += 1
            if shuui_kuro_kazu == 0:
                print("No")
                exit(0)

print("Yes")


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

int main(){
	int N;
	string s,t;
	cin >> N >> s >> t;
	
	for(int i=N;i>0;i--){
		for(int j=0;j<i;j++){
			if(s[N-i+j]!=t[j])break;
			if(j==i-1){
				cout << 2*N-i << endl;
				return 0;
			}
		}
	}
	cout << 2*N << endl;
	return 0;
}

Measured memory_bytes: 256
a, b = input().split(" ")
a = int(a)
b = int(b)
if b > a:
    a, b = b, a
case1 = 0
case2 = 0
case3 = 0
case4 = 0
if a % 3 == 0:
    case1 = 0
else:
    case1 = b

if b % 3 == 0:
    case2 = 0
else:
    case2 = a

con1 = round(a / 3)
sum1 = con1 * b

con2 = a - con1
sum2 = b // 2 * con2
sum3 = (b - b // 2) * con2
case3 = (max(sum3, max(sum2, sum1)) - min(sum3, min(sum2, sum1)))

con1 = round(b / 3)
sum1 = con1 *a 

con2 = b - con1
sum2 = a // 2 * con2
sum3 = (a - a // 2) * con2
case4 = (max(sum3, max(sum2, sum1)) - min(sum3, min(sum2, sum1)))

print(min(min(case3,case4), min(case1, case2)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int HP = sc.nextInt();
		int A = sc.nextInt();
		
		int cnt = 0;
		for(;;) {
			HP -= A;
			cnt++;
			if(HP <= 0) {
				break;
			}
		}

		System.out.print(cnt);

		sc.close();

	}

}

Measured memory_bytes: 23892
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

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

const int  maX=1e5+10;
int a[2005];
int main()
{
    ll n,k;
    sff(n,k);
    ll ara[n];
    ll dp[maX];
    for(ll i=0;i<n;i++)dp[i]=infinity;
    dp[0]=0;
    for(ll i=0;i<n;i++){
        sf(ara[i]);
        for(ll j=1;j<=k;j++){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(ara[i]-ara[i-j]));
            }
        }
    }
    pfn(dp[n-1]);

return 0;
}


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

#define endl '\n'

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

    int n;
    cin >> n;
    vector <int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    int ans = -1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i != j) {
                ans = max(ans, abs(A[i] - A[j]));
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
//constexpr int inf = INT_MAX;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}


int main() {

	int h, w;
	std::cin >> h >> w;
	int n;
	std::cin >> n;

	int ans = inf;
	int cnt = 1;
	while (1) {
		if (cnt * h >= n) {
			ans = cnt;
			break;
		}
		++cnt;
	}

	cnt = 1;
	while (1) {
		if (cnt * w >= n) {
			ans = std::min(ans, cnt);
			break;
		}
		++cnt;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s; R(s);
    W((count(ALL(s),'o')+15-SZ(s)>=8)?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int gcd(int n, int m)
{
	return m == 0 ? n : gcd(m, n % m);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int g = 0;
	int n;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		g = gcd(x, g);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
A=[]
for i in range(H):
    a=input()
    A.append(a)
B=[]
for i in range(H):
    if A[i]!='.'*W:
        B.append(A[i])
C=[]
for k in range(W):
    c=[]
    for i in range(len(B)):
        c.append(B[i][k])
    C.append(c)

D=[]
for i in range(W):
    if C[i]!=['.']*len(B):
        D.append(C[i])
E=[]
for k in range(len(B)):
    e=[]
    for i in range(len(D)):
        e.append(D[i][k])
    E.append(e)

for h in range(len(E)):
    print(''.join(E[h]))



Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		long p=a[0];
		for(int i = 1;i<n;i++) {p=p*a[i]/Gcd(p,a[i]);}
		Console.WriteLine("{0}",p);
	}
	static long Gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 17944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 99999999
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long ans = 0;
    cin >> n;
    vector<int> v(n);
    int a, b, c;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        c = a+b;
        v[i] = c;
        ans -= b;
    }
    /*
      for(vector<int> tmp : v) {
          cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
      }
      */
    sort(v.begin(), v.end(), greater<>());
    for(int i = 0; i < n; i += 2) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
N, Q = (int(i) for i in input().split())
S = input()

AC_list = [0] * (N+1)
 
val=0
for i in range(N-1):
    if(S[i+1]=="C"):
        if(S[i]=="A"):
            val +=1

    AC_list[i+1] = val
AC_list[i+2] = val

for i in range(Q):
    l, r = (int(_) for _ in input().split())
    if(r!=N):
        if(S[r-1]=="A" and S[r]=="C"):
            print(AC_list[r]-AC_list[l-1]-1)
        else:
            print(AC_list[r]-AC_list[l-1])
    else:
        print(AC_list[r]-AC_list[l-1])



Measured memory_bytes: 6188
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e7+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

void solve() {
   int n;
   cin>>n;
   map<string,int> mp;
   rep(i,0,n) {
	      string s;
	      cin>>s;
	      mp[s]++;
	   }
	
	string p="";
	p="AC";
	cout<<p<<" "<<"x "<<mp[p]<<endl;
	p="WA";
	cout<<p<<" "<<"x "<<mp[p]<<endl;
	p="TLE";
	cout<<p<<" "<<"x "<<mp[p]<<endl;
	p="RE";
	cout<<p<<" "<<"x "<<mp[p]<<endl;
	   
   					   
 }

    
int32_t main() {
	cool;
	int t=1;
	

	//cin>>t;
	while(t--)
	  solve();


return 0;	   
}


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

#define ll long long

int main() {
  ll a, b;
  char op;

  while (true) {
    cin >> a >> op >> b;
    if (op == '?') break;
    if (op == '+') cout << a + b;
    if (op == '-') cout << a - b;
    if (op == '*') cout << a * b;
    if (op == '/') cout << a / b;
    cout << "\n";
  }
  cout << flush;

  return 0;
}
  

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();++i){
    cout<<(char)((s[i]-'A'+n)%26+'A');
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= 0; i--)
#define gos(i, a, n, step) for (ll i = a; i < n; i += step)
#define show(a) cout << a << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();

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

    int n;
    cin >> n;
    int k = 1000;
    if (n % 1000)
        k = k * ((n / 1000) + 1);
    else
        k *= (n / 1000);
    show(k - n);

    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

Measured memory_bytes: 3800
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        int l[] = new int[n];
        int left[] = new int[n];
        int right[] = new int[n];
        Pair[] pairs = new Pair[n];
        for (int i = 0 ; i < n ; i++) {
            x[i] = sc.nextInt();
            l[i] = sc.nextInt();
            Pair pair = new Pair();
            pair.from = x[i] - l[i];
            pair.end = x[i] + l[i];
            pairs[i] = pair;
        }

        Arrays.sort(pairs);
        int index = pairs[0].end;
        int count = 1;
        for (int i = 1 ; i < n ; i++) {
            if (index <= pairs[i].from) {
                count++;
                index = pairs[i].end;
            }
        }
        System.out.println(count);


    }

}

class Pair implements Comparable {
    int from;
    int end;
    @Override
    public int compareTo(Object other) {
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}


Measured memory_bytes: 94516
f a n k
  | n == 0 = a
  | a < k = f (a * 2) (n - 1) k
  | a >= k = f (a + k) (n - 1) k
main = do
  n <- fmap read getLine
  k <- fmap read getLine
  putStrLn $ show $ f 1 n k

Measured memory_bytes: 508
# -*- coding: utf-8 -*-
# 整数の入力
# 料理の時間
# ABC 丼
A = int(input())
# ARC カレー
B = int(input())
# AGC パスタ
C = int(input())
# APC ラーメン
D = int(input())
# ATC ハンバーグ
E = int(input())

# 10で割り切れるかを判断させる
order_list         = [A, B, C, D, E]
ordered_order_list = []
counter = 0

# 10で割り切れるものを先に、10で割った余りが最大のものを最後にする
for i, order in enumerate(order_list):
#  print("------------------")
#  print(str(i))
#  print(str(order))
#  print(ordered_order_list)
    
    
  # 最初のものはまずリストに挿入
  if i == 0:
#    print('最初のもの')
    ordered_order_list.append(order)
    if order % 10 ==0:
       counter += 1
    continue

#  # 10で割り切れるものしかないときは最後に挿入
#  if(len(ordered_order_list) == counter):
#    ordered_order_list.append(order)
#    continue

  # 10で割り切れるときは最初に挿入
  if order % 10 == 0:
    ordered_order_list.insert(0, order)
    counter += 1
  # そうでない場合は最後尾と1の位同士を比較し、1の位が小さいほうを最後尾にする
  else:
#    print('そうでないもの')
    order_units_digit        = order % 10
#    print(str(order_units_digit))
    target_order             = ordered_order_list[len(ordered_order_list) -1]
    target_order_units_digit = target_order % 10
#    print(str(target_order_units_digit))
    if(target_order_units_digit > order_units_digit):
      ordered_order_list.append(order)
    else:
      ordered_order_list.insert(len(ordered_order_list) -1, order)
       
answer = 0
#print(ordered_order_list)
for l, ordered_order in enumerate(ordered_order_list):
  if l == len(ordered_order_list) - 1:
    answer += ordered_order
    continue
  if(l<counter):
    answer += ordered_order
  else:
    answer += (int(ordered_order/10) + 1) * 10

# 出力
print(str(answer))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 unordered_map<string,long long >arr;
int main()
{  int n;
 cin>>n;

 //string arr[n+1]={0};
 int de_count=0;
 for(int i=1;i<=n;i++)
 { string s;
  cin>>s;

    if(arr[s]==0)
    { de_count++;
    arr[s]=1;}

 }
cout<<de_count<<endl;

}


Measured memory_bytes: 17644
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') COUT("Yes");
  else COUT("No");
}


Measured memory_bytes: 3596
while True:
  n = int(input())
  if n == 0:
    break
  days = [[] for _ in range(31)]
  for i in range(n):
    hima = list(map(int, input().split()))
    for d in hima[1:]:
      days[d].append(i)
  
  tos = [{i} for i in range(n)]
  end = {i for i in range(n)}
  for i in range(31):
    gather = set()
    for to in days[i]:
      gather = gather | tos[to]
    if gather == end:
      print(i)
      break
    for to in days[i]:
      tos[to] = gather
  else:
    print(-1)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*Aを各々の部分列がいずれも単調非減少または単調非増加となるように
切るとき、最小で何個の部分列に切り分けられるか
*/
/*
*/
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
      cin >> A[i];
  }
  int count = 0;
for(int i = 0;i<N;i++){
    //同じならスキップ
    while(i+1<N && A[i] == A[i+1]) i++;
    //増加
    if(i+1 < N && A[i] < A[i+1]){
        while(i+1 < N && A[i] <= A[i+1]) i++;
    }

    //減少
    else if(i+1 <N && A[i] > A[i+1]){
        while(i+1 < N && A[i] >= A[i+1]) i++;
    }
   count++;
}
cout << count << endl;
}
  

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){

	string s,t;
	cin>>s>>t;
	s.push_back(t[t.length()-1]);
	if(s.compare(t)==0){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}

	return 0;
}

Measured memory_bytes: 3624
def main():
  n=int(input())
  s=input()
  sl,sr=[0],[0]# sl:(,  sr:)
  l,r=0,0
  for si in s:
    if si=='(':
      l+=1
    else:
      r+=1
    sr.append(r)
    sl.append(l)
  ans=n
  al,ar=0,0
  for i in range(n):
    if s[i]=='(':
      a=(sl[n]-sl[i+1])-(ar+sr[n]-sr[i+1])
      if a>=0:
        ar+=a+1
    else:
      a=sr[i]-(al+sl[i+1])
      if a>=0:
        al+=a+1
  print('('*al+s+')'*ar)
if __name__=='__main__':
  main()

Measured memory_bytes: 3064
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
 
const int N = 3e3 + 5;
double p[N], dp[N][N] = {1};
int n;
 
inline void readInput() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
}
 
inline void solve() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= i + 1; j++)
			dp[i + 1][j] += p[i] * dp[i][j - 1] + (1 - p[i]) * dp[i][j];
	double ans = 1;
	for (int i = 0; i <= n / 2; i++)
		ans -= dp[n][i];
	cout << fixed << setprecision(10) << ans << endl;
}
 
int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 46464
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  //rep(i,n) scanf("%d",&a[i]);
  result = n*m;
  printf("%lld", result);
  
  return 0;
}



Measured memory_bytes: 1688
N = int(input())
T, A = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
near = 100000
index = 1

for i in range(N):
  avg = T - arr[i] * 0.006
  avg_sub = A - avg
  # print(avg_sub)
  if avg_sub < 0:
    avg_sub *= -1
  if near > avg_sub:
    near = avg_sub
    index = i + 1
# print(near)
print(index) 

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

using namespace std;

typedef long long ll;

signed main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    vector<int> in(n, 0);
    for(int i = 0; i < m; ++i){
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        edges[x].push_back(y);
        ++in[y];
    }
    queue<int> que;
    for(int i = 0; i < n; ++i)
        if(in[i] == 0)
            que.push(i);

    vector<int> dp(n, 0);

    while(!que.empty()){
        int t = que.front();
        que.pop();
        for(auto& x : edges[t]){
            if(--in[x] == 0)
                que.push(x);
            dp[x] = max(dp[x], dp[t] + 1);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}


Measured memory_bytes: 6528
// EDPC A - Frog 1

#include <bits/stdc++.h>
using namespace std;

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

	int dp[N] = {0};
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char input[5];
    int num[4];
    scanf("%s",input);
    int a,b,c,d;
        a=input[0]-'0';
        b=input[1]-'0';
        c=input[2]-'0';
        d=input[3]-'0';
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a-b-c-d==7)
        printf("%d-%d-%d-%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
    else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
    return 0;
}


Measured memory_bytes: 128
P = 2019
S=input()
N = len(S)
ans=0

rem = [0]*P
mod = 0
ten = 1
rem[mod]=1
for i in range(N):
    mod=(mod+int(S[N-i-1])*ten)%P
    ten=ten*10%P
    rem[mod]+=1
for j in rem:
    ans+=(j*(j-1))//2
print(ans)

Measured memory_bytes: 9300
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
ans=10**9
T=T*1000
A=A*1000
j=0
for i in range(N):
  if abs(A-(T-6*H[i]))<=ans:
    ans=abs(A-T+6*H[i])
    j=i
print(j+1)

Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long sum=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A.at(i);
  }
  for(int i=0;i<N-1;i++){
    if(A.at(i)>A.at(i+1)){
      sum+=A.at(i)-A.at(i+1);
      A.at(i+1)=A.at(i);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 4056