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

#define int long long

signed main() {

  int t;
  cin >> t;

  bool f[20001] = {};

  for ( int p = 0; p < 150; p++ ) {
    for ( int q = 0; q < 150; q++ ) {
      int k = p * p + q * q;
      if ( k <= 20000 ) f[k] = true;
    }
  }

  for ( int i = 0; i < t; i++ ) {

    int p, q;
    cin >> p >> q;

    int cnt = 0;
    for ( int m = 1; m < 150; m++ ) {
      for ( int n = 0; n <= m; n++ ) {
	int k = m * m + n * n;
	int r = p * p + q * q;
	if ( ( r % k ) == 0 && f[r/k] == true ) {
	  cnt++;
	}
      }
    }
    if ( cnt <= 2 ) {
      cout << "P" << endl;
    }else {
      cout << "C" << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1176
/*----------------------------------------
			Author: kkkstra
----------------------------------------*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
inline int read()
{
	char ch = getchar();
	int f = 1, x = 0;
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = c - (a - b);
	printf("%d\n", ans >= 0 ? ans : 0);
	return 0;
}

Measured memory_bytes: 256
l,r=map(int, input().split())

if r-l > 2019:
    s=list(range(0, 2019))
else:
    s=set()
    for i in range(l, r+1):
        s.add(i%2019)
    s=list(s)

ans=float('inf')
for i in range(len(s)):
    for j in range(i+1, len(s)):
        ans=min(ans, (s[i]*s[j])%2019)

print(ans)


Measured memory_bytes: 3188
#include <unordered_set>
#include <cstdio>
#include <string>
 
int main() {
  std::unordered_set< std::string > dict;
  int n; // number of entries
 
  scanf("%d", &n);
  
  for (int i = 0; i < n; ++i) {
    char cmd[7] = {0}; //command
    char word[13] = {0}; //word to store
    scanf("%s %s", cmd, word);
 
    if (cmd[0] == 'i') { // if insert
      dict.insert(word);
    } else {
      std::unordered_set < std::string >::const_iterator got = dict.find(word);
      if (got == dict.end()) { // if word not found
	printf("no\n");
      } else { // if word found
	printf("yes\n");
      }
    }
  }

}

Measured memory_bytes: 28512
#include <stdio.h>
int main()
{
          int n , i, x, count = 0 ;
          scanf("%d%d", &n, &x) ;
          int d[n] , l[n] ;
          d[0] = 0 ;
          for (i = 0 ; i < n ; i++)
          {
                    scanf("%d", &l[i]) ;
          }
           for (i = 1 ; i < n ; i++)
          {
                    d[i] = d[i-1] + l[i-1] ;

          }
          for (i = 0 ; i <= n ; i++)
          {
                    if(d[i] > x) break ;
                              count++ ;

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


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

using namespace std;

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

	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '7') { cout << "Yes\n"; return 0; }
	}

	cout << "No\n";

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
 
int main(void){
  long long int N, A, B;
  cin >> N >> A >> B;
  
  long long int ans=0;
  ans += (N/(A+B))*A;
  if(A<(N%(A+B))){
    ans+= A;
  }else{
    ans += N%(A+B);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  xs <- f
  unless (all (==0) xs) $ do
    solve (g xs) <$> (g <$> f) <*> (g <$> f) >>= putStrLn
    main
  where
    f = map read <$> words <$> getLine :: IO [Int]
    g [x1, y1, x2, y2] = let v1 = Vect (fromIntegral x1) (fromIntegral y1)
                             v2 = Vect (fromIntegral x2) (fromIntegral y2)
                         in Segment v1 v2

solve :: Segment Double -> Segment Double -> Segment Double -> String
solve s1 s2 s3
  | not (is1 && is2 && is3) = "kyo"
  | eps > 1900000 - a = "dai-kichi"
  | eps > 1000000 - a = "chu-kichi"
  | eps > 100000 - a = "kichi"
  | eps < a = "syo-kichi"
  | otherwise = "kyo"
  where
    is1 = intersectSS s1 s2
    is2 = intersectSS s2 s3
    is3 = intersectSS s3 s1
    v1 = crossPoint s1 s2
    v2 = crossPoint s2 s3
    v3 = crossPoint s3 s1
    a = area v1 v2 v3

data Vect a = Vect {vecX :: a, vecY :: a} deriving Show
data Segment a = Segment {segB :: Vect a, segE :: Vect a} deriving Show
data PosRel = CCW | CW | OB | OF | OS deriving (Show, Read, Eq)

eps :: Floating a => a
eps = 1e-9

norm :: Num a => Vect a -> a
norm (Vect x y) = x ^ 2 + y ^ 2

dot :: Num a => Vect a -> Vect a -> a
dot (Vect x1 y1) (Vect x2 y2) = x1 * x2 + y1 * y2

cross :: Num a => Vect a -> Vect a -> a
cross (Vect x1 y1) (Vect x2 y2) = x1 * y2 - y1 * x2

(.+.) :: Num a => Vect a -> Vect a -> Vect a
(Vect x1 y1) .+. (Vect x2 y2) = Vect (x1 + x2) (y1 + y2)

(.-.) :: Num a => Vect a -> Vect a -> Vect a
(Vect x1 y1) .-. (Vect x2 y2) = Vect (x1 - x2) (y1 - y2)

(.*.) :: Num a => Vect a -> a -> Vect a
(Vect x y) .*. k = Vect (x * k) (y * k)

ccw :: (Ord a, Floating a) => Vect a -> Vect a -> Vect a -> PosRel
ccw v1 v2 v3
  | c > eps = CCW
  | c < negate eps = CW
  | dot v12 v13 < negate eps = OB
  | norm v12 < norm v13 = OF
  | otherwise = OS
  where
    v12 = v2 .-. v1
    v13 = v3 .-. v1
    c = cross v12 v13

intersectSS :: (Ord a, Floating a) => Segment a -> Segment a -> Bool
intersectSS s1 s2 = f s1 s2 && f s2 s1
  where
    f x y = case (ccw (segB x) (segE x) (segB y), ccw (segB x) (segE x) (segE y)) of
             (CCW, CW) -> True
             (CW, CCW) -> True
             (OS, CCW) -> True
             (OS, CW) -> True
             (CCW, OS) -> True
             (CW, OS) -> True
             _ -> False

crossPoint :: (Ord a, Floating a) => Segment a -> Segment a -> Vect a
crossPoint s1 s2 = segB s1 .+. ((segE s1 .-. segB s1) .*. t)
  where
    bv = segE s2 .-. segB s2
    d1 = abs $ cross bv $ segB s1 .-. segB s2
    d2 = abs $ cross bv $ segE s1 .-. segB s2
    t = d1 / (d1 + d2)

area :: (Floating a) => Vect a -> Vect a -> Vect a -> a
area v1 v2 v3 = 0.5 * abs (cross v12 v13)
  where
    v12 = v2 .-. v1
    v13 = v3 .-. v1



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

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int ans = 1;
    if(n%2 == 0){
        rep(i, n/2){
            if(s[i]!=s[n/2+i]){
                ans = 0;
                break;
            }
        }
        printf("%s", ans?"Yes":"No");
    }
    else {
        cout << "No";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		String ans = "";
		for (int i = 0; i < s.length(); i += 2)
			ans += s.charAt(i);
		
		System.out.println(ans);
		
		sc.close();
	}
}




Measured memory_bytes: 47360
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int> > a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
      a[i][j]--;
    }
  }
  int ans=1e9;
  vector<int> used(m,0);
  vector<int> bp(n,0);
  bool f=true;
  for(int i=0;i<m;i++){
    vector<int> sp(m,0);
    for(int j=0;j<n;j++){
      while(bp[j]<m&&used[a[j][bp[j]]]==1)bp[j]++;
      if(bp[j]==m){
        f=false;
        break;
      }
      sp[a[j][bp[j]]]++;
    }
    if(!f)break;
    int id=-1;
    int ms=-1;
    for(int i=0;i<m;i++){
      if(ms<sp[i]){
        ms=sp[i];
        id=i;
      }
    }
    ans=min(ans,ms);
    used[id]=1;
  }
  cout<<ans<<endl;
}


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

ll gcd(ll n, ll m){
   if(n % m== 0){
    return m;
   }return gcd(m, n%m);
}
int main(){
    ios :: sync_with_stdio(false);
    ll N, X, ans;
    cin >> N >> X;
    ans = 3*(N - gcd(N, X));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<std::pair<i64, int>> v;
    for (int i = 0; i < n; i++) {
        int a;
        i64 b;
        std::cin >> a >> b;
        v.emplace_back(b, a);
    }
    std::sort(v.begin(), v.end(), std::greater<>());
    std::vector<i64> f(n + 1, std::numeric_limits<i64>::min());
    i64 curr = 0;
    std::set<int> kinds;
    std::multiset<i64> q;
    for (int i = 0; i < k; i++) {
        curr += v[i].first;
        if (!kinds.insert(v[i].second).second) {
            q.insert(v[i].first);
        }
    }
    f[kinds.size()] = curr;
    for (int i = k; i < n && !q.empty(); i++) {
        if (!kinds.insert(v[i].second).second) continue;
        auto it = q.begin();
        curr = curr - *it + v[i].first;
        f[kinds.size()] = curr;
        q.erase(it);
    }

    i64 ret = 0;
    for (i64 i = 1; i <= n; i++) ret = std::max(ret, f[i] + i * i);
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 7024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long sumN = 0;

		for(long i = 1; i <= N; i++ ) {
			if(i % 3 == 0 || i % 5 == 0) {

			}else {
				sumN = sumN + i;
			}
		}

		System.out.println(sumN);
	}

}


Measured memory_bytes: 35828
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

set<int> s;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ms(x,a) memset(x,a,sizeof x)
#define se second
#define fi first
#define lowbit(x) (x&-x)
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define coint const int
typedef long long ll;
using namespace std;
template<class T>inline T rd(){
	static char ch;static bool neg;static T x;
	for(neg=0,ch=0; ch>'9'||ch<'0'; neg|=(ch=='-'),ch=getchar());
	for(x=0; ch<='9'&&ch>='0'; x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar());
	return neg?-x:x;
}
template<class T>inline T Max(const T &x, const T &y){
	return x>y?x:y;
}
template<class T>inline T Min(const T &x, const T &y){
	return x<y?x:y;
}
coint N=1e5+5;
int A[N];
char str1[10],str2[10];


int main(){
	scanf("%s %s",str1+1,str2+1);
	int cnt=(str1[1]==str2[1])+(str1[2]==str2[2])+(str1[3]==str2[3]);
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll k = a / d;
    if(a % d != 0)
    k++;
    ll l = c / b;
    if(c % b != 0)
    l++;
    cout << (k < l ? "No" : "Yes") << endl;
}

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

using namespace std;

int solve(){
    int house,generator; cin >> house >> generator;
    int a[house];
    for(int j=0;j<house;j++){
        cin >> a[j];
    }
    int b[house-1];
    int sum = 0;
    for(int j=0;j<house-1;j++){
        b[j] = a[j+1]-a[j];
        sum += b[j];
    }
    sort(b,b+house-1);
    reverse(b,b+house-1);
    int j=0;
    while(generator-1 != 0 && sum!=0){
        sum -= b[j];
        j++;
        generator--;
    }
    return sum;
}

int main(){
    int n; cin >>n;
    for(int i=0;i<n;i++){
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1956
using System;

class Program
{
    static void Main()
    {
        var str = Console.ReadLine().Split(' ');

        var W = int.Parse(str[0]);
        var H = int.Parse(str[1]);
        var x = int.Parse(str[2]);
        var y = int.Parse(str[3]);
        var r = int.Parse(str[4]);

        Console.WriteLine("{0}", (0 <= x - r && x + r <= W) && (0 <=y - r && y + r <= H) ? "Yes" : "No");
    }
}


Measured memory_bytes: 7880
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   }

Measured memory_bytes: 36580
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    s =list(input())
    if s[0] == s[1] == s[2]:
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  int k,s;
  cin>>k>>s;
  int soc=1;
  int ans=0;
  while(soc<s)
  {
  	soc--;
  	soc+=k;
    ans++;
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 256
N,X=map(int,input().split(' '))
l = 1
p = 1
L=[]
P=[]
for i in range(N):
    l = 2*l+3
    p = 2*p+1
    L.append(l)
    P.append(p)
def pans(l,x):
    if l==1:
        return list('BPPPB'[:x]).count('P')
    elif x<=L[l-2]+1:
        return pans(l-1,x-1)
    else:
        return P[l-2]+1+pans(l-1,x-(2+L[l-2]))
print(pans(N,X))

Measured memory_bytes: 3188
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        String s1=sc.nextLine();
        //String s2=sc.nextLine();
        int ind=s1.indexOf(" ");
        ind++;
        for(int i=0;i<n;i++,ind++)
        {
            System.out.print(s1.charAt(i));
            System.out.print(s1.charAt(ind));
        }
    }
}

Measured memory_bytes: 24916
#22:07
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
  b.append((b[-1]+a[i])%m)
b.sort()
#print(b)
ans = 0
tmp = 0
for i in range(1,n+1):
  if b[i-1] == b[i]:
    tmp += 1
  else:
    tmp = 0
  ans += tmp
print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, d, ans = 0;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> x.at(i).at(j);
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int y = 0;
      for (int k = 0; k < d; ++k) {
        y += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k));
      }
      for (int l = 1; l <= y; ++l) {
        if (y == l * l) {
          ++ans;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
int H,N;
  cin>>H>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
 // cout<<vec[0];
int sum=0;
  for(int i=0;i<N;i++){
    sum+=vec[i];
  }
  
  if(sum>=H){
    cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;
      }
  
}



Measured memory_bytes: 640
#include<cstdio>
int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}

Measured memory_bytes: 1052
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{

    vector<int> par;
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        for(int i=0;i<n;i++) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y) {
        // データの根ノードを得る
        x = find(x);
        y = find(y);
        // 既に同じ木に属しているならマージしない
        if (x == y) return;
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y]) swap(x, y);
        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x) {
        return sizes[find(x)];
    }
};
int main(){
    int n, q;
    cin >> n >> q;
    UnionFind UF(n);
    while(q--){
        int t, u, v;
        cin >> t >> u >> v;
        if(t==0) UF.unite(u, v);
        else cout << UF.same(u, v) << endl;
    }
}

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

int MAX_N = (1 << 25);
long long N, SA, SB, SC, TA, TB, TC;
long long dp[1 << 25], dp2[1 << 25];

int main() {
	cin >> N >> SA >> SB >> SC >> TA >> TB >> TC;

	for (int i = 1; i < MAX_N; i++) dp[i] = -(1 << 30); dp[0] = N;
	for (int i = 0; i < MAX_N - TA; i++) dp[i + TA] = max(dp[i + TA], dp[i] - SA);
	for (int i = 0; i < MAX_N - TB; i++) dp[i + TB] = max(dp[i + TB], dp[i] - SB);
	for (int i = 0; i < MAX_N - TC; i++) dp[i + TC] = max(dp[i + TC], dp[i] - SC);

	for (int i = 1; i < MAX_N; i++) dp2[i] = -(1 << 30); dp2[0] = 0;
	for (int i = 0; i < MAX_N - TA; i++) dp2[i + TA] = max(dp2[i + TA], dp2[i] + SA);
	for (int i = 0; i < MAX_N - TB; i++) dp2[i + TB] = max(dp2[i + TB], dp2[i] + SB);
	for (int i = 0; i < MAX_N - TC; i++) dp2[i + TC] = max(dp2[i + TC], dp2[i] + SC);
	for (int i = 0; i < MAX_N - 1; i++) dp2[i + 1] = max(dp2[i + 1], dp2[i] + 1LL);

	long long maxn = 0;
	for (int i = 0; i < MAX_N; i++) {
		if (dp[i] < 0) continue;
		maxn = max(maxn, dp2[i + dp[i]]);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 524672
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 
 
int main() {
  int a,b;
  cin>>a>>b;
  int c=-1;
  if(a>9){
    cout<<c;
    return 0;
  }
  if(b>9){
    cout<<c;
    return 0;
  }
  c=a*b;
  cout<<c;

}



Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 S          PIC X(100).
01 qt         PIC 9(10).
01 rm         PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT S.
  DIVIDE N BY 2 GIVING qt REMAINDER rm.
  IF ZERO = rm
    IF S(1 : N / 2) = S(N / 2 + 1 : N / 2)
      DISPLAY "Yes"
    ELSE
      DISPLAY "No"
    END-IF
  ELSE
    DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3888
//Author- Simanta Deb Turja
//Team- AUST_HoyeJabe

#include<bits/stdc++.h>
#define pi acos(-1)

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
//typedef push_back pb;


using namespace std;

int SieveOfEratosthenes(int n)
{

    bool prime[n+1];
    ull count = 0;
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {

            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }


    for (int p=2; p<=n; p++)
       if (prime[p])
          count++;
 return count;
}

int main()
{
    int n;
    while(cin>>n){
        cout<<SieveOfEratosthenes(n)<<endl;
    }


    return 0;
}

Measured memory_bytes: 3948
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int x;
    cin >> x;
    while(1) {
        bool ok = true;
        for(int i = 2;i<x;i++) {
            if(x%i == 0) ok = false;
        }
        if(ok) break;
        x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// #include <boost\version.hpp>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define INF 1145141919
#define MINF -1145141919
#define y0 y1919810

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main() {
	string s; cin >> s;
	for(char j = 'a'; j <= 'z'; j++) {
		bool a = false;
		for(int i = 0; i < s.length(); i++) {
			// 存在したら 存在しているかの変数に代入してbreakするゾ
			if(s[i] == j) {
				a = true;
				break;
			}
		}
		if(a == false) {
			cout << j << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return	0;
}


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

const int INF = 1000000000;

class Union_Find{
private:
    std::vector<long long> data; //data[i] : 頂点iの親
public:
    Union_Find(int n){
        data.resize(n,-1);
    }
    //頂点iの親を返す
    int root(int i){
        if(data[i] < 0)return i;
        else return data[i] = root(data[i]);
    }
    //連結
    void unit(int i,int j){
        i = root(i);j = root(j);
        if(i != j){
            data[i] += data[j];
            data[j] = i;
        }
    }

    //頂点iの属する集合の頂点数
    int size(int i){
        i = root(i);
        return -data[i];
    }
};



int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    Union_Find uni(n);
    vector<int> ans(n);

    for(int i = 0; i < m; i++){
        int a,b; cin >> a >> b;
        a--; b--;
        uni.unit(a,b);
        ans[a]++;
        ans[b]++;
    }

    for(int i = 0; i < k; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        if(uni.root(a) != uni.root(b))continue;
        ans[a]++;
        ans[b]++;
    }

    for(int i = 0; i < n; i++){
        cout << uni.size(i) - ans[i] - 1 << " ";
    }



}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){
        vi a(n);
        rep(i,n) cin >> a[i];
        if(n%2){
            a.push_back(INF);
            n++;
        }

        int dp[300][300]={};

        for(int k = 1; k < n; k += 2){
            rep(i, n-k+1){
                if(dp[i+1][i+k-1] == k-1){//間が全部消える
                    dp[i][i+k] = dp[i+1][i+k-1] + (abs(a[i] - a[i+k]) <= 1) * 2;
                }
                for(j = i+1; j <= i+k-1; j += 2){
                    dp[i][i+k] = max(dp[i][i+k], dp[i][j]+dp[j+1][i+k]);
                }
            }
        }

        cout << dp[0][n-1] << endl;
    }
}



Measured memory_bytes: 3464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var temp = n[2];
        for(int i = 1; i <= 10; i++)
        {
            temp = temp * n[0] - n[1];
            WriteLine(temp);
        }
    }
}


Measured memory_bytes: 18984
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

int main(){
  int N,K;
  cin>>N>>K;
  if(!(0<=K && K<=(N-2)*(N-1)/2)){
    cout<<-1<<endl;
    return 0;
  }
  
  
  vector<P>ans;
  //ウニの構築
  for(int i=2;i<=N;i++){
    ans.push_back({1,i});
  }
  //ちょうどK個になるよう減らす
  vector<P>ve;
  for(int i=2;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      ve.push_back({i,j});
    }
  }
  for(int i=0;i<(N-2)*(N-1)/2-K;i++){
    ans.push_back(ve[i]);
  }
  
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
 
  return 0;
}




Measured memory_bytes: 3712
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
using namespace::std;
int main(){

  int N;
  int D;
  cin>>N>>D;
  vector<vector<double>> data(N, vector<double>(D));

  int count=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>data[i][j];
    }
  }
  double p=0;
  
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
   
      for(int k=0;k<D;k++){
        p=p+(data[i][k]-data[j][k])*(data[i][k]-data[j][k]);
      }
      
      p=sqrt(p);
      if(ceil(p)==floor(p)){
        count++;
      }
      p=0;
        
    
    
    }
  }
  cout<<count;
  
  
  
}


Measured memory_bytes: 256
/**********************
 * Author: Cloud_     *
 * Date:   19.04.2020 * 
 * Time:   17.53.32   *
 *                    *
***********************/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

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

const int N=10009;

int main()
{
  fastio; 
  ll i,n,m,ar[N],sum=0;
  cin>>n>>m;
  for(i=1; i<=m; i++)
  {
  	cin>>ar[i];
  	sum+=ar[i];
  }
  if(sum>n) cout<<-1<<endl;
  else cout<<n-sum<<endl;
  return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int N, M;
cin >> N >> M;
vector<int>ball(N, 1);
vector<bool>flag(N, false);
flag.at(0) = true;

REP(i, M){
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  ball.at(x)--;
  ball.at(y)++;
  if(flag.at(x) == true) flag.at(y) = true;
  if(ball.at(x) == 0) flag.at(x) = false;
}

int cnt = 0;
REP(i, N) if(flag.at(i)) cnt++;

print(cnt);


}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

if N % 2 != 0:
	print("No")
else:
	if S[:N//2] == S[N//2:]:
		print("Yes")
	else:
		print("No")
	

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int A,B,T; cin >> A>>B>>T;
    
    cout << (T / A) * B << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

void bfs(mat G, ll r, vector<bool>& f, vec& y)
{
    queue<ll> Q;
    Q.push(r);
    f[r] = true;
    while(!Q.empty()) {
        ll v = Q.front(); Q.pop();    
        FORR(nv,G[v]) {
            if(!f[nv]) {
                Q.push(nv);
                y[nv] += y[v];
                f[nv] = true;
            }
        }
    }
}


int main()
{
    ll N, Q;
    cin >> N >> Q;
    mat G(N);
    REP(i,0,N-1) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }
    vec y(N, 0);
    REP(i,0,Q) {
        ll p, x;
        cin >> p >> x;
        --p;
        y[p] += x;
    }
    
    vector<bool> f(N, false);
    bfs(G, 0, f, y);
    REP(i,0,N) PS(y[i]);
    PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 28528
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	int a,b,c;
    std::cin>>a>>b;
    if(b<=9){
        a=a*10;
    }else if(b<=99){
        a=a*100;
    }else{
        a=a*1000;
    }
    c=a+b;
    int num=0;
    while(num*num<=c){
        num++;
        if(num*num==c){
            std::cout<<"Yes"<<std::endl;
            return 0;
        }
    }
    std::cout<<"No"<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{

ll n;
cin>>n;
vector<ll>sura;
for(ll i=0;i<n;i++)
{
    ll d;
    cin>>d;
    sura.push_back(d);

}
ll ans=0;
sort(sura.begin(),sura.end());
for(ll i=0;i<n;i++)
{
    for(ll j=i+1;j<n;j++)
    {
        for(ll k=j+1;k<n;k++)
        {
          if(sura[i]+sura[j]>sura[k] && (sura[i]!=sura[j] && sura[j]!=sura[k] && sura[k]!=sura[i]))
          ans++;
        }
    }
}
cout<<ans<<endl;

}



   
      
    
        



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i,n) cin >> h[i];

	if(n <= k){
		cout << 0 << endl;
		return;
	}
	sort(h.begin(), h.end());

	ll res = 0;
	rep(i,n-k) res += h[i];
	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	
	int n,number,card[4][13]={0};
	char mark;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>mark>>number;
		switch(mark){
			case 'S': card[0][number-1]=1;
					  break;
			case 'H': card[1][number-1]=1;
					  break;
			case 'C': card[2][number-1]=1;
					  break;
			case 'D': card[3][number-1]=1;
					  break;
		}				
	}
	
	for(int k=0;k<4;k++){
		for(int j=0;j<13;j++){
			if(card[k][j]==0){
				switch(k){
					case 0:cout<<"S ";
							break;
					case 1:cout<<"H ";
							break;
					case 2:cout<<"C ";
							break;
					case 3:cout<<"D ";
							break;		
				}
				cout<<j+1<<endl;
			}
		}
	}
			
	return 0;
}

Measured memory_bytes: 3076
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  for i in range(1, 10):
    if n % i != 0:
      continue
    for j in range(1, 10):
      if i*j == n:
        print('Yes')
        return 
  print('No')

if __name__=='__main__':
  main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

int main(){
	ll N,M;
	cin >> N >> M;
	vector<pll> ba;
	rep(i,M){
		ll a,b;
		cin >> a >> b;
		a--,b--;
		ba.push_back(make_pair(b,a));
	}
	sort(All(ba));

	//first: b, second: a
	ll before = -1;
	vector<bool> bridge(N-1,true);
	for(ll i=0;i<M;i++){
		if(ba[i].second <= before && before < ba[i].first){
			continue;
		}else{
			before = ba[i].first - 1;
			bridge[before] = false;
		}
	}

	ll ans = 0;
	for(ll i=0;i<N-1;i++){
		if(!bridge[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char [] b = in.next().toCharArray();
        if (b [0] == '9' || b [1] == '9' ){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}












Measured memory_bytes: 23764
// バブルソート
#include<iostream>
#include<algorithm>
using namespace std;

static const int MAX_N = 100;

void bubbleSort(int A[], int n);

int main(void)
{
    int N;
    int ary_sequence[MAX_N];

    cin >> N;

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

    bubbleSort(&ary_sequence[0], N);

    return 0;
}

// バブルソートを実施する関数
void bubbleSort(int A[], int n)
{
    int count = 0, j = 0, tmp;
    int flag = 1;

    while( flag )
    {
        flag = 0;

        for(int i = n - 1; i > j; i--)
        {
            if( A[i - 1] > A[i] )
            {
                // 値の入れ替え
                tmp = A[i];
                A[i] = A[i - 1];
                A[i - 1] = tmp;

                flag = 1;

                // 交換回数の保存
                count++;
            }
        }

        j++;
    }

    // 結果表示用
   for(int i = 0; i < n; i++)
   {
       if( i )
       {
           cout << ' ';
       }

       cout << A[i];
   }

   cout << endl;
   cout << count << endl;

    return;
}



Measured memory_bytes: 3088
from math import sqrt
n = int(input())
k = (1+sqrt(1+8*n))/2
if k.is_integer():
    print('Yes')
    k = int(k)
    ans = [set() for _ in range(k)]
    i = 1
    for j in range(k-1):
        for l in range(j+1,k):
            ans[j].add(i)
            ans[l].add(i)
            i += 1
    print(k)
    for a in ans:
        print(k-1,' '.join(map(str,a)))
else:
    print('No')


Measured memory_bytes: 58460
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int hantei(int n){
  int i;
  if(n<2) return 0;
  else if(n == 2) return 1;
  if(n%2==0) return 0;
  for(i=3;i*i<=n;i+=2){
    if(n%i==0) return 0;
  }
  return 1;
}

int main(){
  int n,i,j,cnt=0,A[10000],data;
  scanf("%d",&n);
  if(n<1 || n>10000) exit(2);
  for(i=0;i<n;i++){
    scanf("%d",&data);
    if(hantei(data)==1)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



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

string S;

int main() {
    cin>>S;
    if(S.size() < 4 || S[0] != 'Y' || S[1] != 'A' || S[2] != 'K' || S[3] != 'I') {
        printf("No");
        return 0;
    }
    printf("Yes");
}


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

using ull = unsigned long long;

int main() {

    int n;
    cin >> n;

    vector<ull> v(n);

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

    
    ull answer = 0;
    int right = 0;

    ull sum = 0;
    ull xorSum = 0;

    for(int left = 0; left < n; ++left) {

        while(right < n && (sum + v[right]) == (xorSum ^ v[right])) {
            sum += v[right];
            xorSum ^= v[right];
            ++right;
        }

        answer += right - left;

        if(right == left) {
            right++;
        }
        else {
            sum -= v[left];
            xorSum ^= v[left];
        }

    }
    
    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 1792
n=int(input())
mod=10**9+7
fra=[1]*(n+2)
inv=[1]*(n+2)
t=1
for i in range(1,n+2):
    t*=i
    t%=mod
    fra[i]=t
t=pow(fra[n+1],mod-2,mod)
for i in range(n+1,0,-1):
    inv[i]=t
    t*=i
    t%=mod
ans=fra[n]
for i in range((n+1)//2,n):
    ans-=fra[i-1]*inv[2*i-n]*fra[i]%mod
    ans%=mod
print(ans)

Measured memory_bytes: 82164
// https://atcoder.jp/contests/abc084/tasks/abc084_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int A, B;
    string S;
    cin >> A >> B >> S;
    REP(i, A)
    {
        if (S[i] == '-')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (S[A] != '-')
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = A + 1; i < A + B + 1; ++i)
    {
        if (S[i] == '-')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	vector<int> coin;
	int p = 1;
	while(p*p<=301){
		coin.push_back(p*p);
		p++;
	}
	int N = coin.size();
	vector<int> ans(301,0);
	ans[0] = 1;
	FOR(i,0,N){
		FOR(j,coin[i],301){
			ans[j] += ans[j-coin[i]];
		}
	}
	while(cin>>N,N){
		cout << ans[N] << endl;
	}
}



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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if( abs( a-c ) <= d || ( abs( a-b ) <= d && abs( c-b ) <= d ) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
      
      
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  rep(i,n){
    if(i<k)ans+=x;
    else ans+=y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    ps = list(map(int, input().split()))
    ans = 0

    for i in range(1, n - 1):
        if ps[i - 1] < ps[i] < ps[i + 1] or ps[i - 1] > ps[i] > ps[i + 1]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = (int)S.size();
    int ans = 0;
    rep(i, 0, N / 2) {
        if (S[i] != S[N - 1 - i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

#define Solved int main()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define forn(i, x) for(int i = 1; i <= x; i++)
#define rep(i, x, y) for(int i = x; i <= y; i++)
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define ll long long
#define ull unsigned long long
#define ld long double
#define mii map<int, int>
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
using namespace std;

inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

const int maxn = 1e9;
const ll inf = 1e18;
//const int mod = 998244353;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int n, a[401];
ll sum[401], dp[401][401];

ll rec(int l, int r) {
    if (l == r) return 0;
    if (dp[l][r]) return dp[l][r];

    dp[l][r] = inf;
    for (int i = l; i < r; i++) {
        dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r));
    }
    return dp[l][r] = dp[l][r] + sum[r] - sum[l - 1];
}

void solve() {
    cin >> n;

    forn (i, n)
        cin >> a[i];

    for (int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + a[i];

    cout << rec(1, n);
}

Solved {
    SpeedForce;
	int tt = 1;
    //cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}

}


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

using namespace std;


constexpr int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long sum = 0;
    for(int i = 0; i < n; i++) {
        sum += a[i];
        sum %= mod;
    }
    long long ans = 0;
    for(int i = 0; i < n ; i++) {
        sum -= a[i];
        if(sum < 0) {
            sum += mod;
        }
        ans += (a[i] * sum);
        ans %= mod;
    }
    ans %= mod;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4824