akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
vector<ll> g[N];
int n;
bool used[N];

void add_edge(int a, int b){
	g[a].push_back(b);
	g[b].push_back(a);
}

int rec(int u){
	used[u] = true;
	int r = 1;
	for(int v: g[u]){
		if(!used[v]) r += rec(v);
	}
	return r==2?0:r;
}

int main(){
	scanf("%d", &n);
	rep(i, n-1){
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		add_edge(a, b);
	}
	cout<<(rec(0)?"First":"Second")<<endl;
	return 0;
}


Measured memory_bytes: 6400
use std::collections::HashSet;

fn main() {
    let n: usize = {
        let mut n = String::new();
        std::io::stdin().read_line(&mut n).ok();
        n.trim().parse().unwrap()
    };

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let line: HashSet<i32> = line.split_whitespace()
                                   .map(|c|c.parse().unwrap())
                                   .collect();
    println!("{}", if n == line.len() { "YES" } else { "NO" });
}

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

int cnt, a[5];
int main()
{
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cnt = 1;
	if (a[0] != a[1]) cnt++;
	if (a[1] != a[2]) cnt++;
    cout << cnt << endl;
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

const ll INF = 1e9+7;

ll kai(ll x) {
    ll ret = 1;
    while (x > 0) {
        ret = ret * x % INF;
        x--;
    }
    return ret;
}

int main() {
    ll Min, Max;
    cin >> Min >> Max;
    if (Min > Max) {
        swap(Min, Max);
    }

    ll ans = 1;
    if (Min == Max) {
        ans = (kai(Min) % INF * kai(Max) % INF * 2) % INF;
    } else if (Max - Min == 1) {
        ans = (kai(Min) % INF * kai(Max) % INF) % INF;
    } else {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

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

  vector<int> b(N);
  int count=0;
  if(N%2==1){
    for(int i=N-1;i>=0;i-=2){
      b.at(count)=a.at(i);
      count++;
    }
    for(int i=1;i<N;i+=2){
      b.at(count)=a.at(i);
      count++;
    }
  }
  else{
    for(int i=N-1;i>0;i-=2){
      b.at(count)=a.at(i);
      count++;
    }
    for(int i=0;i<N;i+=2){
      b.at(count)=a.at(i);
      count++;
    }
  }
  for(int i=0;i<N;i++){
    cout << b.at(i);
    if(i!=N-1)  cout << " ";
    if(i==N-1)  cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int main()
{
	string a, b;
    cin >> a >> b;
    string c = (a + b);
    long long x = 0;
    for(int i = 0; i < (int)c.size(); i ++){
   		x = x * 10 + (c[i] - '0');
    }
    long long y = 1;
    while(y * y < x) y ++;
    if(y * y == x) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int[] h = new int[N];
    long s = 0;
    for (int i = 0; i < N; i++) {
      h[i] = scanner.nextInt();
      s += (h[i] - 1) / A + 1;
    }

    long left = -1;
    long right = s;
    while (right - left > 1) {
      long mid = (left + right) / 2;
      if (possible(A, B, h, mid)) {
        right = mid;
      } else {
        left = mid;
      }
    }
    System.out.println(right);
  }

  private static boolean possible(int A, int B, int[] harray, long pmax) {
    long p = 0;
    for (int h : harray) {
      if (h <= pmax * B) continue;
      long pi = (h - pmax * B - 1) / (A - B) + 1;
      p += pi;
      if (p > pmax) return false;
    }
    return true;
  }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  int count = 0;
  
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
    if(H.at(i)>=K){count++;}
  }
  
  cout << count<< endl;
  
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> height(N);
    for(int i = 0; i < N; i++) cin >> height[i];
    vector<int> dp(N, 1000000000);
    dp[0] = 0;
    for(int i = 1; i < N; i++) {
        for(int j = i - 1; j >= max(0, i - K); j--)
            dp[i] = min(dp[i], dp[j] + abs(height[j] - height[i])); 
    }
    
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T> struct grid : public vector<vector<T>> {
    int n, m;
    grid(int n, int m) : vector<vector<T>>(n, vector<T>(m)), n(n), m(m) {}
    grid(int n, int m, T zero) : vector<vector<T>>(n, vector<T>(m, zero)), n(n), m(m) {}
    grid(const grid& a) : vector<vector<T>>(a), n(a.n), m(a.m) {}
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<double> p(n);
    cin >> p;
    grid<double> prob(n + 1, n + 1);
    for(int h = n; h >= 0; h--) {
        for(int t = n; t >= 0; t--) {
            if(h + t == n) {
                prob[h][t] = h > t;
            } else if(h + t < n) {
                prob[h][t] = p[h + t] * prob[h + 1][t] + (1 - p[h + t]) * prob[h][t + 1];
            }
        }
    }
    cout << fixed << setprecision(9) << prob[0][0] << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF  int(1e6+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	vector<bool>a(3,0);
	int x, y;
	cin >> x >> y;
	a[x - 1] = true;
	a[y - 1] = true;
	rep(i, 0, 3)if (!a[i])cout << i + 1 << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		while(a!=0){
			int n = sc.nextInt();
			int[][] its = new int[a][b];
			int[] cx = new int[n];
			int[] cy = new int[n];
			for(int i=0; i<n; i++){
				cx[i] = sc.nextInt() - 1;
				cy[i] = sc.nextInt() - 1;
				its[cx[i]][cy[i]] = -1;
			}
			its[0][0] = 1;
			int flag = 0;
			for(int i=1; i<a; i++){
				if(flag==0 && its[i][0]==0){
					its[i][0] = its[i-1][0];
				}
				else{
					flag -= 1;
				}
			}
			flag = 0; 
			for(int i=1; i<b; i++){
				if(flag==0 && its[0][i]==0){
					its[0][i] = its[0][i-1];
				}
				else{
					flag -= 1;
				}
			}
			for(int i=1; i<a; i++){
				for(int j=1; j<b; j++){
					if(its[i][j]==0){
						if(its[i-1][j]>=0 && its[i][j-1]>=0){
							its[i][j] = its[i-1][j] + its[i][j-1];
						}
						else{
							its[i][j] = Math.max(its[i-1][j]+its[i][j-1]+1, 0);
						}
					}
				}
			}
			System.out.println(its[a-1][b-1]);
			a = sc.nextInt();
			b = sc.nextInt();
		}
	}
}


Measured memory_bytes: 26180
n, k = map(int, input().split())
lis = [n+1]
l = n+1
mod = 10**9+7
for i in range(2, n+2):
    new_l = (l + n -2*i + 2) %mod
    lis.append(new_l)
    l = new_l
s = 0
for i in lis:
    s += i
    s %= mod
s_2 = 0
for i in range(k-1):
    s_2 += lis[i]
    s_2 %= mod
ans = (s- s_2)%mod
if ans < 0:
    ans += mod
print(ans)


Measured memory_bytes: 16864
n=int(input())
a=sorted(list(map(int,input().split())))
m=-a[0]
for i in a[1:-1]:
  if i<0:m-=i
  else:m+=i
m+=a[-1] 
print(m)
b,c=a[0],a[-1]
for i in a[1:-1]:
  if i>0:
    print(b,i)
    b-=i
  else:
    print(c,i)
    c-=i
print(c,b)

Measured memory_bytes: 87440
H, W = map(int,input().split())
S = [list(input()) for i in range(H)]

N = [[10**9]*W]*H
l = 0
u = 0
if S[0][0] == '#' :
    N[0][0] = 1
else :
    N[0][0] = 0
for i in range(H) :
    for j in range(W) :
        if i == 0 and j == 0 :
            continue
        #横移動
        l = N[i][j-1]
        #縦移動
        u = N[i-1][j]

        if S[i][j-1] == '.' and  S[i][j] == '#' :
            l += 1
        if S[i-1][j] == '.' and  S[i][j] == '#' :
            u += 1
        N[i][j] = min(l,u)

print(N[-1][-1])

Measured memory_bytes: 9232
a=int(input())
b=int(input())
c=int(input())
m=int(input())//50
ans=0
for x in range(1+min(a,m//10)):
  n=m-10*x
  for y in range(1+n//2):
    z=n-2*y
    if y<=b and z<=c:
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  long k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
 
  int inner = 0;
  int outer = 0;
 
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
    	if( a[i] <= a[j]) {
				continue;
			}
		
     	 outer++;
			if( j >= i ){
				inner++;
			}
    }
  }
  long mod = 1000000007;
 long ans = k * (k - 1) / 2 % mod;
	ans = (ans*outer + k*inner) % mod;
  cout << ans << endl;
  return 0;
}


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

const int MAX = 555;
int N ,M, V;
vector<int> G[MAX];
vector<int> rG[MAX];
bool used[MAX];
int cmp[MAX];
vector<int> vs;

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
  
void dfs(int v){
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}
  
void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0 ; i < (int)rG[v].size() ; i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
  
int scc(){ //?????£?????????????§£????????????
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v = 0 ; v < V ; v++){
    if(!used[v]) dfs(v);
  }   
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1 ; i >= 0 ; i--){
    if(!used[vs[i]]) rdfs(vs[i],k++);
  }
  return k;
}

int ord[MAX], low[MAX];
struct edgeB{
  int u,v;
};
 
void dfs(int u, int pre, int &c, vector<int> G[], vector<edgeB> &B){
  ord[u] = low[u] = c++;
  for(int i=0;i<(int)G[u].size();i++){
    int v = G[u][i];
    if(v != pre){
      if(ord[v] == -1){
        dfs(v,u,c,G,B);
        low[u] = min(low[u],low[v]);
      }
      else{
        low[u] = min(low[u],ord[v]);
      }
      if(ord[u] < low[v]) B.push_back((edgeB){u,v});
    }
  }
}
 
void bridge(int n, vector<int> G[], vector<edgeB> &B){
  B.clear();
  int c = 0;
  fill(ord,ord+n,-1);
  for(int i=0;i<n;i++) if(ord[i]==-1) dfs(i,-1,c,G,B);
}


int A[1111],B[1111];

void make_graph(int x){
  for(int i=0;i<N;i++) G[i].clear();
  for(int i=0;i<N;i++) rG[i].clear();
  for(int i=0;i<M;i++){
    if( i == x ) continue;
    add_edge( A[i], B[i] );
  }
}

void make_graph2(int x){
  for(int i=0;i<N;i++) G[i].clear();
  for(int i=0;i<M;i++){
    if( i == x ) continue;
    G[A[i]].push_back( B[i] );
    G[B[i]].push_back( A[i] );
  }
}

int main(){
  cin >> N >> M;  
  V = N;
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i]; --A[i]; --B[i];
  }
  if( N == 3 ){
    cout << "YES" << endl; return 0;
  } else if( M == N-1 ){
    cout << "NO" << endl; return 0;
  }
  
  for(int i=0;i<M;i++){
    make_graph(i);
    int n = scc();
    if( n == N ){
      make_graph2(i);
      vector<edgeB> E;
      bridge( N, G, E );
      if( E.size() >= 2 ) {
	cout << "YES" << endl; return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 1284
import sys

def solve():
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    B = []
    Ans = [[-1 for _ in range(W)] for i in range(H)]
    count = 1
    lastH = -1
    for h in range(H):
        S = input().strip("\n")
        last = -1
        for w in range(W):
            if S[w] == "#":
                last = w
        if last >= 0:
            for w in range(W):
                if S[w] == "#":
                    Ans[h][w] = count
                    for dh in B:
                        Ans[dh][w] = count
                    count += 1
                else:
                    if w < last:
                        Ans[h][w] = count
                        for dh in B: Ans[dh][w] = count
                    else:
                        Ans[h][w] = count - 1
                        for dh in B: Ans[dh][w] = count - 1
            B.clear()
            lastH = h
        else:
            B.append(h)
    if len(B) > 0:
        for h in B:
            for w in range(W):
                Ans[h][w] = Ans[lastH][w]

    for h in range(H):
        print(*Ans[h], sep=" ")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 12228
// Ninjo ~ khaledalam.net@gmail.com
#include <bits/stdc++.h>
using namespace std;
#define sz(A)      (int)(A).size()
#define all(B)     (B).begin(),(B).end()
#define ios        ios_base::sync_with_stdio(0);
#define file       freopen("input.txt", "r", stdin)

int main() {
	set<int> s;
	int a;
	for (int i = 0; i < 3; ++i) {
		cin >> a;
		s.insert(a);
	}
	cout << sz(s);
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char a[27]="abcdefghijklmnopqrstuvwxyz";
	char s[100005];
    int ch[27]={0},i;
    while(cin>>s)
    {
    	for(i=0;i<strlen(s);i++)
        ch[s[i]-'\0'-97]++;
    for(i=0;i<26;i++)
    if(ch[i]==0){printf("%c\n",i+97);break;}
    if(i==26)cout<<"None"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt()
    var ans = 0
    for (a <- 1 to math.sqrt(m).toInt) {
      if (m % a == 0) {
        val b = m / a
        if (a.toLong * n <= m) ans = math.max(ans, a)
        if (b.toLong * n <= m) ans = math.max(ans, b)
      }
    }
    println(ans)
  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt()

    def check(k: Int): Int = {
      if (m % k == 0) return k
      else check(k - 1)
    }

    println(check(m / n))
  }

}


Measured memory_bytes: 27300
# input
N, L = map(int, input().split())
flavour = [(L + i - 1) for i in range(1, N + 1)]
sum1 = sum(flavour)
sum2 = []

# main
for i in range(len(flavour)):
    sum2.append(abs(sum1 - sum(flavour[:i] + flavour[i+1:])))

# output
print(sum1 - flavour[sum2.index(min(sum2))])

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N, K;
	cin >> N >> K;

	const LL MOD = 1e9 + 7;

	LL ret = 0;
	FOR(k, K, N + 2){
		LL a = k * (2 * N - (k - 1)) / 2;
		LL b = k * (0 + (k - 1)) / 2 - 1;
		ret += a - b;
		ret %= MOD;
		// if(k < K + 10) cerr << k << " " << ret << " " << a << " " << b << endl;
	}

	cout << ret <<endl;

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int num[20];
int res[100000];
 
int main(){
 
    int n,m,temp;
    cin >> n >> m;
    for(int i=0;i<m;i++){
    cin >> temp;
    num[i] = temp;
    res[temp] = 1;
    }
    bool flag=true;
    while(flag){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        if(res[i] > 0 ){
            if(res[i+num[j]] == 0) res[i+num[j]] = res[i]+1;
            else{res[i+num[j]] = min(res[i+num[j]],res[i]+1);
            if(i+num[j] == n) flag = false;
            }
        }
        }
    }
    }
     
    cout << res[n]<< endl;
 
    return 0;
}

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

int main(void) {
    int num; cin >> num;
    for(int r = 0; r <  num; r++) {
        int a, b, c; cin >> a >> b >> c;
        if(a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)  cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return(0);
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long N = stdIn.nextLong();
		long A = stdIn.nextLong();
		long B = stdIn.nextLong();
		
		if((B-A)%2 == 0) System.out.println((B-A)/2);
		else {
			if(B-1 < N-A) {
				System.out.println(Math.min((B-A-1)/2+1+(A-1),B-1));
			}
			else {
				System.out.println(Math.min((B-A-1)/2+1+(N-B),N-A));
			}
		}

	}

}

Measured memory_bytes: 22228
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/02 10:24:06 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	l, s;
	cin >> l >> s;
	vector<string>	L(l);
	rep(i, l)
		cin >> L.at(i);
	vector<string>	S(s);
	rep(i, s)
		cin >> S.at(i);
	rep(i, l - s + 1)
	{
		rep(j, l - s + 1)
		{
			bool	flag;
			flag = true;
			rep(k, s)
			{
				string	temp;
				temp = L.at(i + k).substr(j, s);
				if (temp != S.at(k))
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 764
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int N = in.nextInt();
	int[] A = new int[N];
	for(int i = 0; i < N; i++) {
	    A[i] = in.nextInt();
	}
	insertSort(N, A);
    }

    public static void insertSort(int N, int[] A) {
	show(A);
	for(int i = 1; i < N; i++) {
	    int v = A[i], j = i - 1;
	    while(j >= 0 && A[j] > v) {
		A[j + 1] = A[j];
		j--;
	    }
	    A[j + 1] = v;
	    show(A);
 	}
    }

    public static void show(int[] A) {
	System.out.println(IntStream.of(A)
			       .mapToObj(String::valueOf)
			       .collect(Collectors.joining(" ")));
    }
}



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

int main(){

  int N = 0;
  cin >> N;

  int h[N] = {};
  int b[N] = {};
  int step = 0;
  int time = 0;
  int j = 0;

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

  // while(j < 2){
  while(true){

    step = 0;
    for(int i = 0 ; i < N ; i++){
      if(h[i] <= 0) b[i] = 0;
      if(h[i] >= 0) b[i] = 1;
      // cout << b[i] << "\t";
    }
    // cout << endl;

    if(b[0] > 0) step++;
    for(int i = 1 ; i < N ; i++){
      if(b[i] > b[i-1]) step++;
    }
    for(int i = 0 ; i < N ; i++){
      h[i]--;
    }
    for(int i = 0 ; i < N ; i++){
      // cout << h[i] << "\t";
    }
    // cout << endl;
    // cout << step << endl;
    if(step == 0) break;
    time += step;
    j++;
  }

  cout << time - 1 << endl;
  
}

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


int main() {
  int A,B,C;
  cin >> A >>B >> C;
  bool checkA=A+B+C==17,checkB=A*B*C==175;

  if(checkA && checkB){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



int main(){
	int i,j,count,n,flag,k;
	char hyou[999999];
	int p[100];
	while(scanf("%d",&n)!=EOF){
		count=0;
		k=0;
		for(i=0;i<=n;i++){
			hyou[i]=0;
		}

		for(i=4;i<=n;i+=2){
			hyou[i]=1;
		}

		j=3;
		while(j<=n){
			for(i=j+j;i<=n;i+=j){
				hyou[i]=1;
			}
			while(hyou[++j]==1){
				if(j>n)break;
			}
		}

		for(i=2;i<=n;i++){
			if(hyou[i]==0){
				count++;
				p[count]=i;
			}
		}
		if(n<=1)count=0;
		printf("%d\n",count);
	}

	return 0;
}

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

int main() {
    int n, m, cnt[35] = {0};
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            cnt[a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int arr[10]={0,};
	for(int i=0;i<4;i++){
		int x; scanf("%d",&x);
		arr[x]++;
	}
	if(arr[1]*arr[7]*arr[9]*arr[4]) printf("YES");
	else printf("NO");
	return 0;
}

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

int main() {
    int n, d;
    cin >> n >> d;
    int MAX = 40 * 40 * d;
    set<int> square;
    for (int i=1; i*i<=MAX; i++) {
        square.insert(i*i);
    }
    vector<vector<int>> x(n, vector<int> (d));
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            int square_dist = 0;
            for (int k=0; k<d; k++) {
                square_dist += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
            }
            if (square.count(square_dist)) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    int len = s.size();
    set<string> st;
    rep(i, 1, 6) {
        rep(j, 0, len - i + 1) {
            st.insert(s.substr(j, i));
        }
    }

    int cnt = 0;
    for (auto i : st) {
        cnt++;
        if (cnt == k) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
    int N,p,k=0;
    cin>>N;
    p=N;
     while(p!=0)
        {
        k=k*10+p%10;
        p=p/10;
        }
        if((N%1111==0)||((N/10)%111==0)||((k/10)%111==0))
           cout<<"Yes";
           else
           cout<<"No";
           return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
double dp[3000][3000];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        vector<double> a(n);
        FOR(i,0,n) cin >> a[i]; 
        cout << fixed << setprecision(10);
        dp[0][0] = 1 - a[0];
        dp[0][1] = a[0];
        FOR(i,1,n)
        FOR(j,0,3000)
        {
            dp[i][j] += (1-a[i])*dp[i-1][j];
            if(j > 0)
                dp[i][j] += a[i]*dp[i-1][j-1]; 
        }
        double ans = 0.0;
        FOR(i,n/2+1,3000)
            ans += dp[n-1][i];
        cout << ans;
    }   
}

Measured memory_bytes: 74116
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
using namespace std;

typedef long long ll;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;

ll mo=1000000007;
ll combi(ll N_, ll C_) {
    const int NUM_=400001;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

int main() {
    int n,p;
    cin>>n>>p;
    vector<int>a(n);
    int even=0,odd=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            even++;
        } else {
            odd++;
        }
    }
    ll ans=0;
    if(p==0){
        ll a1=pow(2,even);
        ll a2=0;
        for(int i=0;i<=odd;i+=2){
            a2+=combi(odd,i);
        }
        ans+=a1*a2;
    } else {
        ll a1=pow(2,even);
        ll a2=0;
        for(int i=1;i<=odd;i+=2){
            a2+=combi(odd,i);
        }
        ans+=a1*a2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
int main()
{
    string s;
    cin >> s;
    vector<int> vec(4);
    for(int i=0;i<4;i++){
        vec[i]=s[i]-'0';
    }
    vector<vector<bool>> reg((1<<3),vector<bool>(3));
    for(int i=0;i<(1<<3);i++){
        for(int j=0;j<3;j++){
            if(i&(1<<j)){
                reg[i][j]=true;
            }
        }
    }
    for(int i=0;i<(1<<3);i++){
        int sum=vec[0];
    //    int nowsum=0;
        for(int j=0;j<3;j++){
            if(reg[i][j]){
                sum += vec[j+1];
            }else{
                sum -= vec[j+1];
            }
        }
        if(sum==7){
         //   cout<<<<endl;
            cout<<vec[0];
            for(int j=0;j<3;j++){
                if(reg[i][j]){
                    cout<<"+";
                }else{
                    cout<<"-";
                }
                cout<<vec[j+1];
            }
            cout<<"=7"<<endl;
            return 0;
        }
    }
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int k, x;
	cin >> k >> x;
	FOR (i, x - k + 1, x + k) cout << i << " ";
    
    return 0;
}



Measured memory_bytes: 3556
<?php


[$N, $M, $Q] = fscanf(STDIN, "%d%d%d");
$smap = array_fill(1, $N, array_fill(1, $N, 0));
for ($i = 0; $i < $M; $i++) {
    [$L, $R] = fscanf(STDIN, "%d%d");
    $smap[$L][$R]++;
}
$ansmap = array_fill(1, $N + 1, array_fill(0, $N + 1, 0));

for ($i = $N; $i > 0; $i--) {
    for ($j = $i; $j <= $N; $j++) {
        $ansmap[$i][$j] = $ansmap[$i][$j - 1] + $smap[$i][$j] + $ansmap[$i+1][$j] - $ansmap[$i+1][$j-1];
    }
}


for ($j = 0; $j < $Q; $j++) {
    [$L, $R] = fscanf(STDIN, "%d%d");
    echo $ansmap[$L][$R].PHP_EOL;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long double L, R;
    cin >> L >> R;
    if (R - L > 2019) cout << 0 << "\n";
    else {
        long long ans = 2018;
        for (long long i = L; i < R; ++i)
            for (long long j = i + 1; j <= R; ++j)
                ans = min(ans, (i * j) % 2019);
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll x; cin>>x;
	ll ans=(x/11)*2;
	if(x%11!=0){
		if(x%11<7) ans++;
		else ans+=2;
	}
	cout<<ans;
	return 0;
}

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

int main()
{
	int n, s, e;
	string w, r, op;
	cin.tie(0);
	cin >> w >> n;

	for (int i = 0; i < n; i++) {
		cin >> op;
		if (op == "replace") {
			cin >> s >> e >> r;
			w = w.substr(0, s) + r + w.substr(e + 1);
		}
		else if (op == "reverse") {
			cin >> s >> e;
			for (int i = 0; i < e - (s + i); i++) swap(w[s + i], w[e - i]);
		}
		else if (op == "print") {
			cin >> s >> e;
			for (int i = s; i <= e; i++) cout << w[i];
			cout << "\n";
		}
	}
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(a) inp(b)
//	b*=2;
	cout<<max((int)0,a-2*b)<<'\n';
	printclock;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
int a[2001][2001];
using namespace std;


int main() {
	lli n,a,b;
	cin >>n>>a>>b;
	cout << min(n*a,b);

}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([f(i // 4) * x + f(i // 2) * y + f(i) * z for x, y, z in A], reverse=True)
    B.append(sum(temp[:m]))
    
print(max(B))

Measured memory_bytes: 3316
t = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}

while 1:
    try:
        s = [t[i] for i in input()]
    except:
        break
    i = 0
    while i < len(s) - 1:
        if s[i] < s[i + 1]:
            s[i + 1] = s[i + 1] - s[i]
            s.pop(i)
        i += 1
    print(sum(s))


Measured memory_bytes: 5560
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 16;
const int M = 1e3 + 5;
const int Mod = 998244353;

struct Base
{
    int m;
    vector <ll> A;

    Base(int m = 0) : m(m)
    {
        A.assign(max(m, 1), 0);
    }

    void insert(ll x)
    {
        for (ll i = m - 1; ~i; --i)
        {
            if (x & (1LL << i))
            {
                if (A[i])
                {
                    x ^= A[i];
                }

                else
                {
                    A[i] = x;
                    break;
                }
            }
        }
    }

    vector <ll> Get()
    {
        vector <ll> Res;

        for (int i = 0; i < m; i++)
            if (A[i])
                Res.push_back(A[i]);

        return Res;
    }
};

int main()
{
    GO;
    int n;
    cin >> n;
    ll XOR = 0;
    vec a(n);
    for (auto& i : a)
        cin >> i, XOR ^= i;
    ll sum = 0;
    for (int i = 59; i >= 0; i--)
    {
        if (XOR >> i & 1)
        {
            for (auto& j : a)
                j &= ~(1LL << i);
            sum += 1LL << i;
            XOR ^= 1LL << i;
            continue;
        }
        Base b(60);
        for (auto j : a)
            b.insert(j >> i);
        ll temp = (XOR >> i) ^ 1;
        for (int j = 59; j >= 0; j--)
            if (temp >> j & 1)
                temp ^= b.A[j];
        if (temp == 0)
            XOR ^= 1LL << i, sum += 2LL << i;
    }
    cout << sum<< endl;
    return 0;
}

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

#define N   100000
#define P      100
#define PN  200000
#define INT(X) \
  ( *( (const int *)(X) ) )

static int d[ P * P ];
static int p[ PN ] = { 1, 1 };
static int pn = 0;

int
compare (
  const void *a,
  const void *b
  )
{
  return ( INT( a ) - INT( b ) );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( i = 2; i * i < PN; ++i )
  {
    if ( p[ i ] ) continue ;
    for ( j = i * i; j < PN; j += i )
      p[ j ] = 1;
  }
  for ( i = 2; i < PN; ++i )
  {
    if ( p[ i ] ) continue ;
    p[ pn++ ] = i;
  }

  for ( ; ; )
  {
    int l, c, s;
    int lp = 0;

    scanf ( "%d%d", &l, &c );
    if ( l == -1 && c == -1 ) break ;

    while ( p[ lp ] <= l )
      ++lp;

    s = 0;
    for ( i = lp; i < lp + P; ++i )
    for ( j = i; j < lp + P; ++j )
    {
      d[ s++ ] = p[ i ] + p[ j ];
    }
    qsort ( d, s, sizeof ( int ), compare );
    printf ( "%d\n", d[ c - 1 ] );
  }

  return ( EXIT_SUCCESS );
}

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

int main()
{
    int n;
    cin >> n;
    vector<long long> h(n);
    for(auto& i : h) cin >> i;

    bool flag = true;
    long long tmp = 0;
    for(int i = 1; i < n && flag; ++i)
    {
        if(h[i] - h[i - 1] <= -2 || (tmp < 0 && h[i] - h[i - 1] < 0)) flag = false;
        if(h[i] - h[i - 1] != 0)tmp = h[i] - h[i - 1];
    }
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main (){
  int N, M;

  while(cin >> N >> M && N > 0){
    int h[1600];
    int w[1600];
    rep(i, N){
      cin >> h[i];
    }
    rep(i, M){
      cin >> w[i];
    }

    vector<int> h_edge(1500000, 0);
    vector<int> w_edge(1500000, 0);
    int len;
    
    rep(i, N){
      len = 0;
      REP(j, i, N){
        len += h[j];
        h_edge[len]++;
      }
    }

    rep(i, M){
      len = 0;
      REP(j, i, M){
        len += w[j];
        w_edge[len]++;
      }
    }

    int count = 0;
    REP(i, 1, 1500000){
      count += h_edge[i] * w_edge[i];
    }

    cout << count << endl;
  }

}



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


unsigned get_digit(int n) {
  unsigned cnt=0;
  while(n!=0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int main() {
  int N,cnt;
  cin >> N;
  
  for (int i=1; i<=N; i++) {
    int digit = get_digit(i);
  	if (digit % 2 != 0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
	cin >> n;
    double a[n];
    double ans=0;
    fr(i,n){
      cin >> a[i];
      ans+=1/a[i];
    }
    
      cout <<setprecision(12)<< 1/ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n,k,q = map(int,input().split())
a = [int(input())-1 for i in range(q)]
cnt = [0]*n
for question in a:
    cnt[question] += 1
#print(cnt)#点数は k-q+cnt > 0
for man in range(n):
    if cnt[man] > q - k: print("Yes")
    else: print("No")

Measured memory_bytes: 8636
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n)         for(int i=0; i<(n); i++)
#define P pair<int, int>
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"

//----------------------------------------------------

const int INF = 100100100;
int a[12][12];

int main(){
    int a, b;
    cin >> a >> b;
    if(b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

vector<vector<int>> G;
vector<int> d;

int dfs(int v) {
    if (d[v] != -1) return d[v];
    int res = 0;
    for (auto nv : G[v]) {
        chmax(res,dfs(nv)+1);
    }
    return d[v] = res;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    G.resize(N);
    rep(i,M) {
        int x,y; cin >> x >> y;
        x--; y--;
        G[x].emplace_back(y);
    }

    d.assign(N,-1);
    int ans = 0;
    rep(i,N) chmax(ans,dfs(i));

    cout << ans << endl;
}

Measured memory_bytes: 7552
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define dreps(i,cc,n) for(int i=cc;i>(n);--i)
#define llreps(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

// A[d]は葉の数

// 0 <= A[d] <= 2^d (d=0,1,2,...)
//

int main()
{
	int A,B;
	cin >> A >> B;

	cout << A*B << endl;
	return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

int main(){
int n;
int a[100000];
int i;
int c;
int b;
int x=0;
scanf("%d",&n);
for(i=0;i<n;i++){
	
	scanf("%d",&a[i]);
	
}
c=1;
b=a[0];
x++;
do{
	c=a[c-1];
	
	
	
	x++;
	
	
	if(x>n){
		
		break;
	}
	
	
	
	
	
	
	}while(c!=2);


	if(x>n){
		
		printf("-1\n");
	}else{
	printf("%d\n",x-1);
	}
	
	

	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct State {
	int i, j, foot, dist;
	const bool operator<(const State &s) const {
		return dist > s.dist;
	}
};

char g[65][35];
int dist[65][35][2];

const int LF = 0, RF = 1;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	for (;;) {
		rep(i, 0, 65) rep(j, 0, 35) g[i][j] = ' ';
		rep(i, 0, 65) rep(j, 0, 35) rep(k, 0, 2) dist[i][j][k] = 9999999;

		int w, h; cin >> w >> h; if (!w && !h) break;
		priority_queue<State> pq;

		for (int i = h - 1; i >= 0; i--)
			rep(j, 0, w) {
				cin >> skipws >> g[i][j];
				if (g[i][j] == 'S') {
					dist[i][j][LF] = dist[i][j][RF] = 0;
					pq.push(State {i, j, LF, 0});
					pq.push(State {i, j, RF, 0});
				}
			}

		while (!pq.empty()) {
			State st = pq.top(); pq.pop();
			if (st.dist > dist[st.i][st.j][st.foot])
				continue;
			for (int di = -2; di <= 2; di++) {
				for (int dj = 1; dj <= 3 - abs(di); dj++) {
					int ni = st.i + di, nj = st.foot == LF ? st.j + dj : st.j - dj;
					int nf = st.foot ^ 1;
					if (0 <= ni && ni < h && 0 <= nj && nj < w) {
						if (isdigit(g[ni][nj]) && st.dist + int(g[ni][nj] - '0') < dist[ni][nj][nf]) {
							dist[ni][nj][nf] = st.dist + int(g[ni][nj] - '0');
							pq.push(State {ni, nj, nf, dist[ni][nj][nf]});
						}
						if (g[ni][nj] == 'T') {
							cout << st.dist << endl;
							goto done;
						}
					}
				}
			}
		}

		cout << -1 << endl;
done: void(0);
	}
}



Measured memory_bytes: 3116
y=[0,1,2,3,4,5,6,7,8,9]

while True:
    n=int(input())
    if n==0:
        break
    x=[]
    z=[0,0,0,0,0,0,0,0,0,0]
    for i in range(n):
        c=int(input())
        x.append(c)
#    print(x)
    
    for i in range(10):
        for j in x:
            if y[i]==j:
                z[i]+=1
                
#    print(z)
    
    for k in range(10):
        if z[k]==0:
            print('-')
        else:
            for l in range(z[k]):
                print('*',end='')
            print()
    
    


Measured memory_bytes: 7680
s = input()
n = len(s)

f = False
ans = s[0] == 'A'
for i in range(1,n):
    if 'a' <= s[i] <= 'z': continue

    if not f and i>1 and i<n-1 and s[i] == 'C':
        f = True
        continue

    ans = False
    break

if ans and f:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

r,d,x0=MI()
answers=[]
x=x0
for i in range(10):
    x=r*x-d
    answers.append(x)
#print(answers)
for ans in answers:
    print(ans)

Measured memory_bytes: 38384
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for i in range(m)]

count_max = 0
for s in set(s_list):
    count = s_list.count(s) - t_list.count(s)
    if count > count_max:
        count_max = count
for t in set(t_list):
    count = s_list.count(t) - t_list.count(t)
    if count > count_max:
        count_max = count

print(count_max)

Measured memory_bytes: 3064
N = input()
ln = len(N)
hon = ['2', '4', '5', '7', '9']
pon = ['0', '1', '6', '8']
if ln == 1:
    if N in hon:
        print('hon')
    elif N in pon:
        print('pon')
    else:
        print('bon')
if ln == 2:
    if N[1] in hon:
        print('hon')
    elif N[1] in pon:
        print('pon')
    else:
        print('bon')
if ln == 3:
    if N[2] in hon:
        print('hon')
    elif N[2] in pon:
        print('pon')
    else:
        print('bon')

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

int main () {
  int N, Y;
  cin >> N >> Y;
  
  int resi = -1, resj = -1, resk = -1;
  for (int i=0; i<=N; i++) {
    for (int j=0; j+i<=N; j++) {
      
      int k=N-i-j;	// 答えが見つかったら
      int sum = 10000*i + 5000*j + 1000*k;
        if (sum == Y) {
          resi = i;
          resj = j;
          resk = k;
      }
    }
  }
  // 答えを出力 (見つかっていなくても -1 -1 -1 になるので OK です)
  cout << resi <<" "<< resj <<" "<< resk << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=2010,mod=1e9+7;
#define inf 0x7fffffff
ll c[N-5][N-5];

int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    for(ll i=0;i<=n;i++)
    {
        c[i][0]=1;
        for(ll j=1;j<=i;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    for(ll i=1;i<=k;i++)
    {
        printf("%lld\n",(c[k-1][i-1]*c[n-k+1][i])%mod);
    }
    return 0;
}


Measured memory_bytes: 30080
from statistics import median

N = int(input())
A = list(map(int,input().split()))
Asort = sorted([A[i]-i-1 for i in range(N)])
# print(Asort)

b_tmp = int(median(Asort))

submin = [abs(A[i]-b_tmp-i-1) for i in range(N)]
# print(submin)
minA = sum(submin)

print(minA)

Measured memory_bytes: 30404
s = list(input())
n = len(s)

def atcg(s):
    slength = len(s)
    cnt = 0
    for i in range(slength):
        if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
            cnt +=1
        else:
            break
    return cnt

ans = []
for i in range(n):
    ans.append(atcg(s[i:]))


print(max(ans))

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

int main(){
	double r,l,a=0,b=0,c=0,d=0,aa=0,bb=0,cc=0,dd=0;
	while(cin>>l>>r){
		if(l>=1.1)a++;
		else if(l>=0.6)b++;
		else if(l>=0.2)c++;
		else d++;
		if(r>=1.1)aa++;
		else if(r>=0.6)bb++;
		else if(r>=0.2)cc++;
		else dd++;
	}
	cout << a << " " << aa << endl << b << " " << bb << endl << c << " " << cc << endl << d << " " << dd << endl;
  return 0;
}

Measured memory_bytes: 0
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
lst=[]


for i in range(1,n+1):
  for j in range(a[i-1]):
    lst.append(str(i))

lst.reverse()
    
ans=[[0]*w for i in range(h)]

for i in range(h):
  if i%2==0:
    for j in range(w):
      ans[i][j]=lst.pop()

  else:
    for j in range(w-1,-1,-1):
      ans[i][j]=lst.pop()

for i in ans:
  print(' '.join(i))


Measured memory_bytes: 68784
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	int a,b;
	String s = buf.readLine();
	String[] strlAry =s.split(" ");
	for(int i=0;i<strlAry.length;i++){
	}	
	a= Integer.parseInt(strlAry[0]);
	b= Integer.parseInt(strlAry[1]);
	System.out.println(a*b+" "+2*(a+b));	
	}
}

Measured memory_bytes: 16956