akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def modpow(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

def modinv(a,mod):
    return modpow(a,mod - 2,mod)

def cnk(a,b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1,MOD) % MOD
    return ret

lis = factorize(M)
ans = 1
for l in lis:
    ans *= cnk(l[1]+N-1,N-1)
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 42344
#include<stdio.h>

int main(void){
    int N;
    int a[200001];
    int ans;
    int sum = 0;
    int check = 999999999;
    double ave;
    scanf("%d", &N);
    for (int b = 0; b < N;b++){
        scanf("%d", &a[b]);
        sum += a[b];
    }
    ave = sum*1.0 / N;
    for (int c = 0; c < N;c++){
        if( (ave-a[c])*(ave-a[c]) < (ave-check)*(ave-check)){
            check = a[c];
            ans = c;

        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

int main() {
	int M, K;
	cin >> M >> K;
	if (K >= (1 << M)) {
		cout << -1 << endl;
		return 0;
	}
	if (M == 1) {
		if (K == 0) {
			cout << "0 0 1 1" << endl;
			return 0;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << K;
	for (int i = 0; i < (1 << M); i++) {
		if (i != K) cout << " " << i;
	}
	cout << " " << K;
	for (int i = (1 << M) - 1; i >= 0; i--) {
		if (i != K) cout << " " << i;
	}
	cout << endl;
}

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

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



Measured memory_bytes: 3084
#include <iostream>

long long int f(long long int n, long long int k, long long int b) {
	if (k >= b) return 0;
	auto q = n / b;
	auto r = n % b;
	if (k == 0) return q * b + r;
	if (k <= r) return q * (b - k) + (r - k + 1);
	else return q * (b - k);
}
int main() {
	long long int n, k;
	std::cin >> n >> k;
	long long int res{ 0 };
	for (auto b = k + 1; b <= n; ++b) {
		res += f(n, k, b);
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=inpm()
        a-=1
        b-=1
        g[a].append(b)
        g[b].append(a)
    return n,m,g
 
def main():
    n=inp()
    s=input()
    r,l=0,0
    ans=[]
    for i in range(n):
        if s[i]=='(':
            r+=1
        elif s[i]==')':
            if r==0:
                l+=1
            else:
                r-=1
    for i in range(l):
        ans.append('(')
    for i in range(n):
        ans.append(s[i])
    for i in range(r):
        ans.append(')')
    print(''.join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 39020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;

int main() {
    int n;
    scanInt(n);
    char s[10001];
    rep(i, 10001) s[i] = '\0';
    scanf("%s", s);
    // A = 65 Z = 90
    for (int i = 0; s[i] != '\0'; ++i) {
        s[i] += n;
        if (s[i] > 90) s[i] -= ('Z' + 1 - 'A');
        printf("%c", s[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String[] words = word.split("");
        int num0 = 0;
        int num1 = 0;

        for (int n = 0; n < words.length; n++) {
            if (words[n].equals("0")) {
                num0 = num0 + 1;
            }
            else {
                num1 = num1 + 1;
            }
        }
         if (num1 > num0) {
            System.out.println(num0 * 2);
        } else if (num0 > num1) {
            System.out.println(num1 * 2);
        } else {
            System.out.println(num1 + num0);
        }
    }
}

Measured memory_bytes: 33144
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    vector<int> res(n,0);
    REP(i,n){
        int temp = 0;
        FOR(j,i,n-1){
            if(temp<=s[j]){
                temp = s[j]+c[j];
            }else{
                temp = (temp+f[j]-1)/f[j]*f[j]+c[j];
            }
        }
        res[i] = temp;
    }
    REP(i,n){
        put(res[i]);
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		n int
	)
	fmt.Scan(&n)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		ints := make([]int, 10)
		for j := 0; j < 10; j++ {
			ints[j] = int(s[j])
		}
		sort.Ints(ints)
		s = ""
		for j := 0; j < 10; j++ {
			s += string(ints[j])
		}
		ss[i] = s
	}
	sort.Strings(ss)
	var ret int64 = 0
	previous := ""
	count := 0
	for i := 0; i < n; i++ {
		if ss[i] == previous {
			count++
			ret += int64(count)
		} else {
			count = 0
		}
		previous = ss[i]
	}
	fmt.Println(ret)
}


Measured memory_bytes: 6656
#include <cstring>
#include <regex>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    string s;
    cin >> s;
    rep(i, s.length() + 1) {
        FOR(j, i, s.length() + 1) {
            if (s.substr(0, i) + s.substr(j, s.length() - j) == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	 // int t ;
	 // cin>>t;
	 // whln(t){
  	ll n;
  	cin>>n;
  	vector<char>v;
  	while(n>0){
  		if(n%26)
  			v.push_back('a'+n%26 -1);
  		else
  			v.push_back('z');
  		n=(n-1)/26 ;
  	}
  	rep(i,v.size())
  		cout<<v[v.size()-i -1] ;
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3628
def printAns( A, index ):
    n = len(A)
    for i in range(0, index):
        print( str( A[i] ), end=" ")
    print( "[" + str(A[index]), end="] ")
    for i in range(index+1, n-1):
        print( str( A[i] ), end=" ")
    print( str( A[n-1] ) )

def partition(A, p, r):
    tmp = 0
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            tmp = A[j]
            A[j] = A[i]
            A[i] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    printAns(A, i+1)
    return i+1

def main():
    n = int( input() )
    A = [int(x) for x in input().split()]
    index = partition(A, 0, n-1)

if __name__ == "__main__":
    main()



Measured memory_bytes: 16388
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast; 
	ll n,x; cin>>n;
	ll a[n];
	for(ll i = 0; i < n; i++)
	{
		cin>>x;
		a[i] = x;
	}
	ll ans1 = 0, ans2 = 0;
  	ll sum1 = 0, sum2 = 0;
 
  for (int i = 0; i < n; ++i) 
  {
    if (i & 1 && sum1 + a[i] <= 0) 
	{
      ans1 += abs(sum1 + a[i]) + 1;
      sum1 = 1;
    } 
	else if (!(i & 1) && sum1 + a[i] >= 0) 
	{
      ans1 += abs(sum1 + a[i]) + 1;
      sum1 = -1;
    } 
	else 
	{
      sum1 += a[i];
    }
  }
 
  for (int i = 0; i < n; ++i) 
  {
    if (!(i & 1) && sum2 + a[i] <= 0) 
	{
      ans2 += abs(sum2 + a[i]) + 1;
      sum2 = 1;
    } 
	else if (i & 1 && sum2 + a[i] >= 0) 
	{
		
      ans2 += abs(sum2 + a[i]) + 1;
      sum2 = -1;
    } 
	else 
	{
      sum2 += a[i];
    }
  }
  cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
d = na()
s = str(n)

ans = []
res1 = 0
res2 = 0

while res1 < n:
    if res1 == 0:
        for i in range(1, 10):
            if i not in d:
                res1 *= 10
                res1 += i
                break
    else:
        for i in range(10):
            if i not in d:
                res1 *= 10
                res1 += i
                break

j = 0
while res2 < n:
    ok = False
    for i in range(10):
        if i not in d and res2 * 10 + i >= int(s[:j + 1]):
            res2 *= 10
            res2 += i
            ok = True
            break
    if not ok:
        res2 = inf
        break
    j += 1

print(min(res1, res2))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){	
	int n,m;
    cin>>n>>m;
    vector<vector<char>> grid(n,vector<char>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>grid[i][j];
        }
    }
    vector<vector<int>> dp(n,vector<int>(m,0));
    dp[0][0]=1;
    for(int i=1;i<m;i++){
        if(grid[0][i]=='#') break;
        dp[0][i]=dp[0][i-1]%1000000007;
    }
    for(int i=1;i<n;i++){
        if(grid[i][0]=='#') break;
        dp[i][0]=dp[i-1][0]%1000000007;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(grid[i][j]=='#') continue;
            if(grid[i-1][j]!='#') dp[i][j]=(dp[i][j]%mod+dp[i-1][j]%mod)%mod;
            if(grid[i][j-1]!='#') dp[i][j]=(dp[i][j]%mod+dp[i][j-1]%mod)%mod;
        }
    }
    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a=0; cin>>n;
  string s,x,y; cin>>s;
  for(int i=1; i<n; i++){
    int cnt=0;
    x=s.substr(0,i);
    y=s.substr(i);
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    y.erase(unique(y.begin(),y.end()),y.end());
    for(char c:x) if(count(y.begin(),y.end(),c)>0) cnt++;
    a=max(a,cnt);
  }
  cout<<a;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] arrStr;
		StringBuilder sb = new StringBuilder();
		try {

			while (true) {
				str = br.readLine();
				arrStr = str.split(" ");

				int h = Integer.parseInt(arrStr[0]);
				int w = Integer.parseInt(arrStr[1]);
				if (h == 0 && w == 0) {
					break;
				}

				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (   (i == 0 || j == 0)
							|| ((i == h - 1) || j == w - 1)) {
							sb.append("#");
						}else{
							sb.append(".");
						}
					}
					sb.append("\n");
				}
				System.out.println(sb.toString());
				sb.setLength(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 20476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> data;
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    int n;
    cin>>n;
    data.push_back(n);
  }
  std::sort(data.begin(),data.end(),std::greater<int>());
  int aris=0;
  for(int j=0;j<N;j++){
    if(j%2==0){
      aris+=data.at(j);
    }else{
      aris-=data.at(j);
    }
  }
  cout << aris<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int a[110][110];
int main(){
	ll w,h,n;
	scanf("%lld%lld%lld",&w,&h,&n);
	rep(i,0,n){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		if(c==1)rep(xx,0,x)rep(yy,0,h)a[xx][yy]++;
		if(c==2)rep(xx,x,w)rep(yy,0,h)a[xx][yy]++;
		if(c==3)rep(xx,0,w)rep(yy,0,y)a[xx][yy]++;
		if(c==4)rep(xx,0,w)rep(yy,y,h)a[xx][yy]++;
	}
	ll ans=0;
	rep(xx,0,w)rep(yy,0,h)ans+=!!a[xx][yy];
	printf("%lld",w*h-ans);
}

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

const int N = 100007;

vector<bool> is_prime(N, true);

void enum_prime() {
  rep(i, N) {
    if (i < 2) is_prime[i] = false;
    if (!(is_prime[i])) continue;
    for (int j = 2*i; j < N; j += i) is_prime[j] = false;
  }
  return;
}

int main() {
  enum_prime();
  vector<int> cum(N, 0);
  rep(i, N) {
    if (i == 0) continue;
    cum[i] = cum[i-1];
    if (i % 2 && is_prime[i] && is_prime[(i+1)/2]) cum[i]++;
  }

  int q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    int ans = cum[r] - cum[l-1];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
vi adj[MAXN];
int mrk[MAXN];

void dfs(int u, int p) {
	for (int v: adj[u]) {
		if (v != p)
			dfs(v, u);
	}
	if (!mrk[p] && !mrk[u])
		mrk[u] = p, mrk[p] = u;
}

int main() {
	int n; ni(n);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d %d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		if (!mrk[i])
			return !printf("First\n");
	printf("Second\n");
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string s;
int dp[20][1000][2][2];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> s;
  int n = s.size();
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 1000; ++j) {
      for(int k = 0; k < 2; ++k) {
	for(int l = 0; l < 2; ++l) {
	  int lim = l ? 9 : s[i]-'0';
	  for(int d = 0; d <= lim; ++d) {
	    int nj = j%100*10+d;
	    int nk = j/10*100+d == 5103;
	    dp[i+1][nj][k||nk][l||d<lim] += dp[i][j][k][l];
	  }
	}
      }
    }
  }

  int ans = 0;
  rep(i, 1000) {
    rep(j, 2) {
      if(~dp[n][i][1][j]) ans += dp[n][i][1][j];
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#define llong long long
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  if (N%K == 0) cout << 0 << endl;
  else cout << 1 << endl;
}

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

int main(){
  int n;
  
  cin >> n;
  
  if(n/100==7 || (n%100)/10==7 || n%10==7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

void dfs(int N, int i, int count, string s, vector<string> &S);

int main()
{
    int N;
    cin >> N;
    vector<string> S;
    string s(N, 'a');
    if (N == 1)
    {
        cout << 'a' << endl;
        return 0;
    }
    int count = 0;
    dfs(N, 0, count, s, S);
    sort(all(S));
    int size = S.size();
    rep(i, 0, size)
    {
        cout << S.at(i) << endl;
    }
}

void dfs(int N, int i, int count, string s, vector<string> &S)
{
    if (i == 0)
    {
        s.at(i) = 'a';
        count++;
        dfs(N, i + 1, count, s, S);
    }
    else if (i == N)
    {
        S.push_back(s);
        return;
    }
    else
    {
        rep(j, 0, count + 1)
        {
            s.at(i) = 'a' + j;
            if (j == count)
            {
                dfs(N, i + 1, count + 1, s, S);
            }
            else
            {
                dfs(N, i + 1, count, s, S);
            }
        }
    }
}

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

int main(){

    int N = 0;
    int d[100000];    

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

    std::sort(d,d+N);

    if(N%2 != 0)    
        std::cout << "0" << std::endl;

    std::cout << d[N/2] - d[N/2-1] << std::endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

const int kN = 200000 + 5;
int n;
std::vector<int> edges[kN];
int dist[kN];
bool win[kN];

int bfs(int u) {
  std::queue<int> que;
  std::fill(dist, dist + n, -1);
  dist[u] = 0;
  que.emplace(u);
  while (!que.empty()) {
    u = que.front(); que.pop();
    for (int v : edges[u]) {
      if (dist[v] == -1) {
        dist[v] = dist[u] + 1;
        que.emplace(v);
      }
    }
  }
  return u;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++ i) {
    int a, b;
    scanf("%d%d", &a, &b); -- a; -- b;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  int d = dist[bfs(bfs(0))] + 1;
  win[1] = true;
  for (int i = 3; i <= d; ++ i) {
    win[i] = !win[i - 1] || !win[i - 2];
  }
  puts(win[d] ? "First" : "Second");
}


Measured memory_bytes: 13556
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
// #include <queue>
using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

bool compare(pair<int,int> i1, pair<int,int> i2) 
{ 
    return (i1.second < i2.second); 
} 

int main(int argc, const char * argv[]) {

  int n, m;
  cin >> n >> m;
  vector< pair<int, int> > py;
  vector< vector <int> > p(n+1);

  rep(i, m) {
    int p_, y;
    cin >> p_ >> y;
    py.push_back(make_pair(p_, y));
    p[p_].push_back(y);
  }

  map<int, int> id;

  repd(i, 1, n+1){
    sort(p[i].begin(), p[i].end());
    rep(j, p[i].size()){
      id[p[i][j]] = j+1;
    }
  }

  rep(i, m){
    printf("%06d", py[i].first);
    printf("%06d\n", id[py[i].second]);
  }

  return 0;
}


Measured memory_bytes: 12404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   ll sum=0;
   rep(i,n){
      cin>>a[i];
      sum+=a[i];
   }
   ll y=0;
   ll ans=INFINITY;
   rep(i,n){
      y+=a[i];
      if(i==n-1) break;
      ans=min(ans,abs(sum-2*y));
   }
   cout<<ans;

   return 0;
}


Measured memory_bytes: 4040
""" C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

M = 1000000007

def _pow(n, m):
    ret = 1
    for _ in range(m):
        ret = (ret * n) % M
    return ret

def main(N):
    return (_pow(10, N) - 2 * _pow(9, N) + _pow(8, N)) % M

if __name__ == "__main__":
    _N = readInteger()

    print(main(_N))

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

int main() {

  int N;
  cin >> N;
  
  vector<int> A(N), B(N);
  
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  for(int i = 0; i < N; i++) {
    B.at(A.at(i)-1) = i+1;
  }
 
  for(int i = 0; i < N; i++) {
    cout << B.at(i) << " ";
  } 
  cout << endl;
  
}

Measured memory_bytes: 3948
#include <cstdio>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef long long ll;

int n;
int x[500];

int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d", &x[i]);
	}
	sort(x, x + n, greater<int>());
	ll a = 1;
	int k = -1;
	rep(i, n){
		if(i % 4 == 0){
			++k;
		}
		a += max(x[i] - k, 0);
	}
	printf("%lld\n", a);
	return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int a,b;
cin>>a>>b;
string s;
cin>>s;
if((a+b+1)!=s.length()) cout<<"No";
else
{
    int f1 = 0,f2 = 0,f3 = 0;
    if(s[a]=='-') f1 = 1;
   // cout<<f1<<endl;
    for(int i =0;i<a;i++)
    {
        if(s[i]=='0'||s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9') f2=1;
        else {
                f2 = 0;
                 break;
        }
    }
   // cout<<f2<<endl;
    for(int i =a+1;i<a+b+1;i++)
    {
        if(s[i]=='0'||s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9') f3=1;
        else {
                f3 = 0;
        break;
        }
    }
   // cout<<f3<<endl;
    if(f1&&f2&&f3) cout<<"Yes";
    else cout<<"No";
}
return 0;
}


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

from bisect import bisect_left, bisect
ans = 0
for b in B:
    i = bisect_left(A,b)
    j = bisect(C,b)
    ans += i * (N-j)
print(ans)

Measured memory_bytes: 29344
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
memo = {}
def solve(s):
    d = [0]*10
    for c in s:
        d[int(c)] += 1
    def dfs(i, d):
        if i == 10:
            return True
        key = tuple(d)
        if s in key:
            return memo[key]
        if d[i] == 0:
            return dfs(i+1, d)
        if d[i] >= 3:
            d[i] -= 3
            r = dfs(i, d)
            d[i] += 3
            if r:
                memo[key] = True
                return True
        if i+2 <= 9 and d[i+1] >= 1 and d[i+2] >= 1:
            d[i] -= 1; d[i+1] -= 1; d[i+2] -= 1
            r = dfs(i, d)
            d[i] += 1; d[i+1] += 1; d[i+2] += 1
            if r:
                memo[key] = True
                return True
        memo[key] = False
        return False
    ans = []
    for k in range(1, 10):
        if d[k] == 4:
            continue
        d[k] += 1
        for i in range(10):
            if d[i] >= 2:
                d[i] -= 2
                r = dfs(0, d)
                d[i] += 2
                if r:
                    ans.append(k)
                    break
        d[k] -= 1
    if not ans:
        ans.append(0)
    return ans

for line in readlines():
    res = solve(line.strip())
    write(" ".join(map(str, res)))
    write("\n")



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

int g[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string p;
  while (cin >> p, p != "#") {
    int curr = 0;
    for (auto &&ch : p) {
      curr = g[curr][ch - '0'];
      if (curr == -1) break;
    }
    cout << (curr == 5 ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3196
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


N, Q = map(int, input().split())
tree = UnionFind(N)
res = []
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(tree.is_connected(u, v)))
    else:
        tree.unite(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 85688
N = int(input())
S = list(input())
x = 0
ls = []
ls.append(x)
for i in range(N):
    if S[i] == 'I':
        x += 1
        ls.append(x)
    elif S[i] == 'D':
        x -= 1
        ls.append(x)

print(max(ls))


Measured memory_bytes: 9204
N = gets.to_i

a = []
N.times{
	a << gets.to_i
}

pairs = 0
i = 0
while i < a.length
	count = a[i]
	if count > 0
		pairs += count / 2
		if i < a.length - 1 && count % 2 == 1
			if a[i + 1] > 0
				a[i + 1] -= 1
				pairs += 1
			end
		end
	end
	i += 1
end
puts pairs



Measured memory_bytes: 2996
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

s=input()
t=input()
idx=0
wk=0
while 1:
    mt=0
    for idx2,val in enumerate(t):
        if s[idx+idx2]==val:
            mt+=1
    wk=max(wk,mt)
    if idx+len(t)>=len(s):break
    else:idx+=1
    
print(len(t)-wk)

Measured memory_bytes: 68864
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const LL INF=1LL<<60;
const int SIZE=3*1e5;
const int BITSIZE=1<<17;
const int TIMES=40;
const LL p=7+1e9;
LL N,M,K,H,W,A,B,X[3];
string S;
LL DP[50][BITSIZE];
LL sums[3];
inline int bits(int x,int t){
	if(t+sums[x]-1<0) return 0;
	return (1<<(t+sums[x]-1));
}
bool able(int bit,int x,int t){
	if(t<0) return false;
	if(x==0 && t==0) return true;
	if(t==0) return able(bit,x-1,X[x-1]);
	return (bit&bits(x,t))!=0;
}

int main(){
	cin >> N >> X[0] >> X[1] >> X[2];
	FOR(j,1,3+1) sums[j]=sums[j-1]+X[j-1];
	DP[0][0]=1;
	REP(i,N){
		REP(j,BITSIZE){
			if(DP[i][j])
			FOR(k,1,8+1){
				int now=j&bits(2,X[2]);
				REP(a,3)
					FOR(b,1,X[a]+1){
						if(able(j,a,b-k)){
							now|=bits(a,b);
						} 
					}
				if(k==8) DP[i+1][now]+=DP[i][j]*3;
				else DP[i+1][now]+=DP[i][j];	
				DP[i+1][now]%=p;
			}
		}
	}
	LL ans=0;
	REP(j,BITSIZE)
		if(able(j,2,X[2])) {
			ans+=DP[N][j];	
			ans%=p;
		}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32896
n, m = gets.split.map(&:to_i)
students = n.times.map { gets.split.map(&:to_i) }
points = m.times.map { gets.split.map(&:to_i) }

students.each do |x, y|
  puts points.index(points.min_by { |p_x, p_y| (x - p_x).abs + (y - p_y).abs }) + 1
end

Measured memory_bytes: 1788
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int h=stdIn.nextInt();
			int w=stdIn.nextInt();
			if(h==0)
				break;
			for(int i=0;i<h;i++){
				if(i==0||i==h-1){
					for(int j=0;j<w;j++)
						System.out.print("#");
				}
				else{
					System.out.print("#");
					for(int j=0;j<w-2;j++)
						System.out.print(".");
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 33984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    pf((n / 500) * 1000 + (n % 500) / 5 * 5);
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import combinations

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main(N,M,X,C, A):
    min_cost = ''
    combs = set()
    for i in range(N):
        for c in combinations(range(N), i+1):
            combs.add(c)

    for comb in combs:
        cost = 0
        xs = [0 for _ in range(M)]
        for c in comb:
            for i in range(M):
                xs[i] += A[c][i]
            cost += C[c]

        if all([x>=X for x in xs]):
            min_cost = cost if min_cost =='' else min(min_cost, cost)

    if min_cost != '':
        print(min_cost)
    else:
        print(-1)

    pass

if __name__ == '__main__':
    C = []
    A = []
    N, M, X = list(map(int, input().split()))
    for n in range(N):
        lst = list(map(int, input().split()))
        # for m in range(M):
        
        c = lst[0]
        a = lst[1:]

        C.append(c)
        A.append(a)

    
    main(N,M,X,C, A)


Measured memory_bytes: 9608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> C(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }

  vector<ll> tmp(200010, -1);
  vector<ll> lst(N, -1);
  for (ll i = 0; i < N; i++)
  {
    lst.at(i) = tmp.at(C.at(i));
    tmp.at(C.at(i)) = i;
  }

  /*
  cerr << endl;
  for (ll i = 0; i < N; i++)
  {
    cerr << lst.at(i) << endl;
  }
  cerr << endl;
  */

  vector<ll> dp(N, 0);
  dp.at(0) = 1;
  for (ll i = 1; i < N; i++)
  {
    dp.at(i) = dp.at(i - 1);
    if (lst.at(i) != -1 && lst.at(i) != i - 1)
    {
      dp.at(i) += dp.at(lst.at(i));
      dp.at(i) %= MOD;
    }
  }

  /*
  for (ll i = 0; i < N; i++)
  {
    cerr << dp.at(i) << endl;
  }
  cerr << endl;
  //*/

  ll ans = dp.at(N - 1);
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//n??????
//Radix r;
//cout << r.to(n, 4) << endl;
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		for (int i = 0; s[i]; i++) a[(int)s[i]] = i;
	}
	string to(long long p, int q) {
		if (!p) return "0";
		char t[64] = {};
		int i;
		for (i = 62; p; i--) {
			t[i] = s[p % q];
			p /= q;
		}
		return string(t + i + 1);
	}
	string to(const string &t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const string &t, int p) {
		long long sm = a[(int)t[0]];
		for (int i = 1; i < (int)t.length(); i++)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

signed main() {
	for (int n; cin >> n&&n;) {
		Radix r("01235789");
		cout << r.to(n, 8) << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
import  java.math.*;
import  java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[][] A = new long[N][N];

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        long[][] res = pow_mod_m(A, N, K);
        int m = (int) 1e9 + 7;

        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                ans += res[i][j];
                ans %= m;
            }
        }

        System.out.println(ans);
    }

    public static long[][] pow_mod_m(long[][] A, int N, long K) {
        long[][] ret = new long[N][N];
        for (int i = 0; i < N; i++) ret[i][i] = 1;

        while (K > 0) {
            if ((K & 1) == 1) ret = mul_m(ret, A, N);
            A = mul_m(A, A, N);
            K >>= 1;
        }
        return ret;
    }

    public static long[][] mul_m(long[][] A, long[][] B, int N) {
        long[][] res = new long[N][N];
        int m = (int) 1e9 + 7;

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    res[i][j] += A[i][k] * B[k][j];
                    res[i][j] %= m;
                }
            }
        }

        return res;
    }
}


Measured memory_bytes: 30120
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int count=0;
  for(int i=0; i<3; i++){
    if(S.at(i)=='a' || S.at(i)=='b' || S.at(i)=='c')
      count++;
  }
  if(count==3 && S.at(0)!=S.at(1) && S.at(1)!=S.at(2) && S.at(0)!=S.at(2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n+1];
  memset(a,-1,sizeof(a));
  int f=0;
  int x,y;
  for(int i=0;i<m;i++)
  {
    cin>>x>>y;
    if(a[x]!=-1)
    {
      if(a[x]!=y)
        f=1;
    }
    else
      a[x]=y;
  }
  if(a[1]==-1 and n==1)
    a[1]=0;
  if(a[1]==-1)
    a[1]=1;
  if(a[1]==0 and n>1)
    f=1;
  if(f)
    cout<<-1<<"\n";
  else
  {
    for(int i=1;i<=n;i++)
    {
      if(a[i]!=-1)
        cout<<a[i];
      else
        cout<<0;
    }
    cout<<"\n";
  }
  return 0;
}


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

main(){
  int n;
  cin>>n;
  vector<double> a(n);
  for(auto&x:a)cin>>x;

  vector<vector<double>> dp (n+1,vector<double>(n+1));
  // dp[i][j]:=i枚見た時にj枚表になる確率
  dp[0][0]=1.0;
  rep(i,n){
    rep(j,n){
      dp[i+1][j+1]+=dp[i][j]*a[i];
      dp[i+1][j]+=dp[i][j]*(1.0-a[i]);
    }
  }
  auto ans=0.0;
  for(int i=(n+1)/2;i<=n;++i)ans+=dp[n][i];
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int N, D, sum = 0, counter = 0;
	cin >> N >> D;
	int a[N][D];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >> a[i][j];
		}
	}
	// 多重配列に入力はできてる
	for(int i = 0; i < N - 1; i++){
		for(int j = i + 1; j < N; j++){
			for(int s = 0; s < D; s++){
				sum += pow(a[i][s] - a[j][s], 2);
			}
			if(pow(sum, 0.5) == int(pow(sum, 0.5))){
				counter++;
			}
			sum = 0;
		}
	}
	// このforループが多分間違ってる
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

int cost[3005][3005];

bool Compare(pii a, pii b)
{
   return cost[a.ff][a.ss] > cost[b.ff][b.ss];
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[j]=1;
		}
	}
}

// https://codeforces.com/blog/entry/79048



void solve(){
	int h,w,m;  cin>>h>>w>>m;
	mpi x,y;
	mpii ss;
	int a[m][2];
	f(i,0,m){
		cin>>a[i][0]>>a[i][1];
		x[a[i][0]]++; y[a[i][1]]++;
		ss[{a[i][0],a[i][1]}]++;
	}
	int mx,my;
	int cx=-1,cy=-1;
	for(auto it : x){
		if(it.ss>cx){
			cx=it.ss;
			mx=it.ff;
		}
	}
	for(auto it : y){
		if(it.ss>cy){
			cy=it.ss;
			my=it.ff;
		}
	}
	vi d,dd; 
	for(auto it : y)
		if(it.ss==cy) d.pb(it.ff);
	for(auto it : x)
		if(it.ss==cx) dd.pb(it.ff);
	int cnt=0;
	for(auto it : d){
		int th=x[mx] + y[it] - 	ss[{mx,it}]++;
		cnt=max(cnt,th);
	}
	for(auto it : dd){
		int th=x[it] + y[my] - 	ss[{it,my}]++;
		cnt=max(cnt,th);
	}
	cout<<cnt;
}

void D(){
	int h,w; cin>>h>>w;
	int ch,cw; cin>>ch>>cw; --ch; --cw;
	int dh,dw; cin>>dh>>dw; --dh; --dw;
	int dx[]={-1,1,0,0};
	int dy[]={0,0,1,-1};
	string s[h]; f(i,0,h) cin>>s[i];
	if(s[ch][cw]=='#' || s[dh][dw]=='#') {
		cout<<"-1\n";
		return ;
	}
    f(i,0,3005) f(j,0,3005) cost[i][j]=INT_MAX;
	cost[ch][cw]=0;
	priority_queue<pii, vector<pii>, function<bool(pii, pii)>> p(Compare);
	p.push({ch,cw});
	while(!p.empty()){
		pii tp=p.top(); p.pop();
		f(i,0,4){
			int cx=tp.ff+dx[i];
			int cy=tp.ss+dy[i];
			if(cx<0 || cy<0 || cx>=h || cy>=w) continue;
			if(s[cx][cy]=='#' )continue;
			if(cost[cx][cy] > cost[tp.ff][tp.ss]) {
				cost[cx][cy]=cost[tp.ff][tp.ss];
				p.push({cx,cy});
			}
		}
		// use magic
		f(i,-2,3) f(j,-2,3){
			int cx=tp.ff+i;
			int cy=tp.ss+j;
			if(cx<0 || cy<0 || cx>=h || cy>=w) continue;
			if(s[cx][cy]=='#') continue;
			if(cost[cx][cy] > cost[tp.ff][tp.ss]+1) {
				cost[cx][cy]=cost[tp.ff][tp.ss]+1;
				p.push({cx,cy});
			}
		}
	}
	if(cost[dh][dw]==INT_MAX)	cost[dh][dw]=-1;
	cout<<cost[dh][dw]<<"\n";
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) D();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 75256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 5;

int n, m, ans;
vi v[N];
vi dp;
void dfs(int s){
    int mx = 0;
    for(int i : v[s]){
        if(dp[i] == 0){
            dfs(i);
        }
        mx = max(mx, dp[i]);
    }
    dp[s] = 1 + mx;
    //cout << s << " " << dp[s] << endl;
    ans = max(ans, dp[s]);
}
void solve(){
    ans = 0;
    cin >> n >> m;
    dp.resize(n + 1);
    for(int i = 0; i <= n; i++) dp[i] = 0;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        v[x].pb(y);
    }
    for(int i = 1; i <= n; i++){
        if(dp[i] == 0){
            dfs(i);
        }
    }
    cout << ans - 1 << endl;
}

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

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 11792
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A+B>=24){
    cout<< A+B-24 << endl;
  }else{
    cout<< A+B << endl;
  }

return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long test(long n) {
		long a = 1;
		for (long i = 1; i <= n; i++) {
			a *= i;
		}

		Set<Long> d = new HashSet<>();
		for (long x = 1; x <= Math.sqrt(a); x++) {
			if (a % x == 0) {
				d.add(x);
				d.add(a / x);
			}
		}

		return d.size();

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		sc.close();

		int[] p = new int[N + 1];

		for (int n = 2; n <= N; n++) {

			int tmp = n;
			int m = 2;
			while (tmp != 1) {
				if (tmp % m == 0) {
					p[m]++;
					tmp /= m;
				} else {
					m++;
				}
			}
		}

		long ans = 1;
		long mod = 1000_000_007;

		for (int i = 2; i < p.length; i++) {
			ans *= (p[i] + 1);
			ans %= mod;
		}

		out.println(ans);
	}

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


Measured memory_bytes: 21844