akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n,m = map(int,input().split())
a = [None]*m;b = [None]*m
ans = 0
for i in range(m):
    a[i],b[i] = map(int,input().split())
for i in range(m):
    check = [False]*n
    a_ls = list(a);b_ls = list(b)
    del a_ls[i],b_ls[i]
    deq = deque()
    num = 1
    deq.append(1)
    check[0] = True
    while not not deq:
        num = deq.pop()
        for i in range(m-1):
            if a_ls[i] == num:
                if check[b_ls[i]-1] == False:
                    deq.append(b_ls[i])
                    check[b_ls[i]-1] = True
            if b_ls[i] == num:
                if check[a_ls[i]-1] == False:
                    deq.append(a_ls[i])
                    check[a_ls[i]-1] = True
    if check.count(False) == 0:pass
    else:ans += 1
print(ans)

Measured memory_bytes: 3316
#import<cstdio>
#import<vector>
#import<algorithm>
main(){for(int i,r,n,p,c;scanf("%d%d",&n,&r),n;){std::vector<int> v;for(i=n;i;i--)v.push_back(i);for(i=0;i<r;i++)scanf("%d%d",&p,&c),p--,std::rotate(v.begin(),v.begin()+p,v.begin()+p+c);printf("%d\n",v[0]);}}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int n = scanner.nextInt();

		int robots[][] = new int[n][2];

		int x, l;
		for (int i = 0; i < n; i++) {
			x = scanner.nextInt();
			l = scanner.nextInt();
			robots[i][0] = x - l;
			robots[i][1] = x + l;
		}

		Arrays.parallelSort(robots, (a, b) -> a[1] - b[1]);

		int filled = Integer.MIN_VALUE;
		int count = 0;

		for (int[] robot : robots) {
			if (filled <= robot[0]) {
				count++;
				filled = robot[1];
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 95000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  ll n;cin>>n;
  string s,ans;cin>>s;
  ans=s;

  stack<int> st;

  for(int i=0;i < n;i++)
  {
    if(s[i]=='('){
      st.push(1);
    }else{
      if(st.empty()){
        ans.insert(ans.begin(),'(');
      }else{
        st.pop();
      }
    }
  }
  while(!st.empty()){
    ans.pb(')');
    st.pop();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/* Code by Saborit */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast") 
#define MX 100005
#define INF (1<<30)
#define EPS 1e-9
#define MOD 1000000007
#define mid (x+xend)/2
#define izq nod*2
#define der nod*2+1
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define unique(X) (X).resize(unique(all(X)) - (X).begin())
#ifdef LOCAL 
	#include "debug.h"
#endif
using namespace std;
using namespace __gnu_pbds;
typedef long long int64;
typedef unsigned long long unt64;

int64 pot(int64 base, int64 e){
	int64 ans = 1;
	
	while( e ){
		if( e & 1ll ) ans = ans * base % MOD;
		base = base * base % MOD;
		e >>= 1ll;
	}
	return ans;
}

int64 inv_mod(int a, int b){
	return a * pot(b, MOD-2) % MOD;
}

int x, y;

int main(void){
    //~ freopen("a.in", "r", stdin);
    //~ freopen("a.out", "w", stdout);
    
    scanf("%d%d", &x, &y);
    
    if( (x + y) % 3 != 0  )
		return !printf("0\n");
	
    int p = (x + y) / 3;
    int f = x - p;
	
	if( f < 0 || p - f < 0 )
		return !printf("0\n");
		
    //~ db() << imie(p) imie(f) << imie(p-f);
    
    int64 fact = 1;
    for(int i=2; i<=p; i++){
		fact *= i;
		fact %= MOD;
	}
	
	int64 den = 1;
	for(int i=2; i<=f; i++){
		den *= i;
		den %= MOD;	
	}
	
	for(int i=2; i<=p-f; i++){
		den *= i;
		den %= MOD;	
	}
	
	//~ db() << imie(fact) imie(den);
	
	fact = inv_mod(fact, den);
	
	printf("%lld\n", fact);
    
   return 0;
}


Measured memory_bytes: 3796
//============================================================================
// Name        : f2.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n;cin>>n;
	vector<string> s(n);
	vector<pair<int,int>> v(n),vp,vm;
	for(int i=0;i<n;i++){
		cin>>s[i];
		vector<char> st;
		for(int j=0;j<s[i].size();j++){
			if(st.size()==0){
				st.push_back(s[i][j]);
			}else if(st.back()=='('&&s[i][j]==')'){
				st.pop_back();
			}else{
				st.push_back(s[i][j]);
			}
		}
		pair<int,int> p;
		p.first=0;
		p.second=0;
		for(int j=0;j<st.size();j++){
			if(st[j]=='('){
				p.second++;
			}else{
				p.first++;
			}

		}
		v[i]=p;
		if(p.second-p.first>0){
			vp.push_back(p);
		}else{
			swap(p.first,p.second);
			vm.push_back(p);
		}
	}


	sort(vp.begin(),vp.end());
	sort(vm.begin(),vm.end());
	reverse(vm.begin(),vm.end());
	int count=0;
	for(int i=0;i<vp.size();i++){
		count-=vp[i].first;
		if(count<0){
			cout<<"No"<<endl;
			return 0;
		}
		count+=vp[i].second;
	}
	for(int i=0;i<vm.size();i++){
			count-=vm[i].second;
			if(count<0){
				cout<<"No"<<endl;
				return 0;
			}
			count+=vm[i].first;
	}
	if(count==0){
	cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

#define MAX 100009
#define INF 99999999
#define MIN -99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long
#define FI	first
#define SE second

using namespace std;
int n;
ll a,b;
int main() {
  cin >> a >> b;
  if(a*b % 2 != 0) cout << "Odd" ;
  else cout << "Even";
  return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  sort(a.begin(),a.end());

  ll ans = 0;
  int k = n-1;
  int cnt = 0;
  while(cnt<n-1){
    ans += a[k];
    cnt++;
    if(cnt%2==1) k--;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, M;
    cin >> N >> M;
    int s = 1, e = M+1;
    for(;e-s > 0;) {
        cout << s << " " << e << endl;
        s++;
        e--;
    }
    s = M+2, e = 2*M+1;
    for(;e-s > 0;) {
        cout << s << " " << e << endl;
        s++;
        e--;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
char A[N];
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int w;scanf("%s%d",A,&w);
	int len=strlen(A);
	for(int i=0;i<len;i+=w)cout<<A[i];
	cout<<'\n';
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    vector<ll> v(N + 1, INF);
    REP(i, N) {
        ll index = lower_bound(v.begin(), v.end(), A[i]) - v.begin();
        v[index] = A[i];
    }

    cout << (lower_bound(v.begin(), v.end(), INF) - v.begin()) << endl;
    return 0;
}


Measured memory_bytes: 4412
#include <iostream>
#include <string>

using namespace std;

string a , b;

int main(){
     cin >> a >> b;
     int y = a.size();
     for(int i = 0 ; i < y; i++){
          string temp ;
          temp+= a[y-1];
          for(int i = 0; i < y-1; i++){temp += a[i];}
          if(temp==b){cout << "Yes"; return 0;}
          else a = temp;
     }
     cout << "No";
     return 0;
}

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

string S;

int main(){
    cin >> S;
    if(S == "SUN")cout <<  7 << endl;
    else if(S == "MON")cout << 6 << endl;
    else if(S == "TUE")cout << 5 << endl;
    else if(S == "WED")cout << 4 << endl;
    else if(S == "THU")cout << 3 << endl;
    else if(S == "FRI")cout << 2 << endl;
    else if(S == "SAT")cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	k := io.NextInt()
	a := io.NextInt()
	b := io.NextInt()
	for i := a; i <= b; i++ {
		if i%k == 0 {
			io.Println("OK")
			return
		}
	}
	io.Println("NG")
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
const int inf=1<<30;
const int N=40005;
int S,T,n,m,top=1,sx,sy,tx,ty,head[N],dis[N],cur[N];
bool vis[N];
char a[105][105];
struct node{
    int too,next,zh;
}edge[N];
void add(int a,int b,int c)
{
    edge[++top].too=b;edge[top].zh=c;
    edge[top].next=head[a];head[a]=top;
}
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
bool bfs()
{
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	memcpy(cur,head,sizeof(cur));
	queue<int>q;
	q.push(S);
	dis[S]=0;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		vis[u]=0;
		for(int i=head[u];i;i=edge[i].next)
		{
			int v=edge[i].too;
			if(dis[v]>dis[u]+1&&edge[i].zh)
			{
				dis[v]=dis[u]+1;
				if(!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
	return dis[T]!=0x3f3f3f3f;
}
int dfs(int u,int flow)
{
	int temp=flow,rlow=0;
	if(u==T)return flow;
	for(int &i=cur[u];i;i=edge[i].next)
	{
		int v=edge[i].too;
		if(dis[v]==dis[u]+1&&edge[i].zh)
		{
			rlow=dfs(v,min(temp,edge[i].zh));
			if(!rlow)dis[v]=0;
			edge[i].zh-=rlow;
			edge[i^1].zh+=rlow;
			if(!(temp-=rlow))break;
		}
	}
	return flow-temp;
}
int dinic()
{
	int ans=0,x;
	while(bfs())
	{
		if(x=dfs(S,inf))ans+=x;
	}
	return ans;
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	S=0;T=n*m+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='S')sx=i,sy=j;
			if(a[i][j]=='T')tx=i,ty=j;
			if(a[i][j]=='o')
			{
				add(i,j+n,1);
				add(j+n,i,0);
				add(j+n,i,1);
				add(i,j+n,0);
			}
		}
	if(sx==tx||sy==ty){puts("-1");return 0;}
	add(S,sx,inf);
	add(sx,S,0);
	add(S,sy+n,inf);
	add(sy+n,S,0);
	add(tx,T,inf);
	add(T,tx,0);
	add(ty+n,T,inf);
	add(T,ty+n,0);
	cout<<dinic();
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int n,m;

int main(int argc, char const *argv[])
{
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


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

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

    if ((B < C && C < A) || (A < C && C < B)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
row_white = []
column_white = []
 
for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            break
        if j == w - 1:
            row_white.append(i)
for i in range(len(row_white)):
    grid.pop(row_white[i] - i)
 
h = len(grid)
for j in range(w):
    for i in range(h):
        if grid[i][j] == '#':
            break
        if i == h - 1:
            column_white.append(j)
for j in range(len(column_white)):
    for i in range(h):
        del grid[i][column_white[j] - j]
for i in range(h):
    print(*grid[i], sep='')

Measured memory_bytes: 4596
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		long N=stdIn.nextLong();
		long m=1,ans=0;
		while(m*m<N){
			if(N%m==0)
				if(N/m-1!=m)
					ans+=N/m-1;
			m++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
map <int,int> m;
int all_(int x){
	int i,j;
	m[x]--;
	for(i=1;i*i<=x;++i){
		if(x%i==0){
			if((x/i)!=i){
				if(m[x/i]>=1 || m[i]>=1){
					m[x]++;
					return 0;
				}
			}
			else{
				if(m[i]>=1){
					m[x]++;
					return 0;
				}
			}
		}
	}
	m[x]++;
	return 1;
}
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i,j,x,c=0;
    vii v;
    cin>>n;
    for(i=0;i<n;++i){
    	cin>>x;
    	v.pb(x);
    	m[x]++;
	}
	//cout<<all_(11)<<'\n';
	for(i=0;i<n;++i){
		if(all_(v[i])){
			c+=1;
		}
	}
	cout<<c;
}

Measured memory_bytes: 32856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._700problems
{
    class AGC024_C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = new int[n];
            for (int i = 0; i < n; i++) array[i] = ReadInt();
            if (array[0] > 0)
            {
                WriteLine(-1);
                return;
            }
            for(int i = 1; i < n; i++)
            {
                if (array[i] > array[i - 1] + 1)
                {
                    WriteLine(-1);
                    return;
                }
            }

            long res = 0;
            for (int i = 1;i< n; i++){
                if (array[i] <= array[i-1])
                {
                    res += array[i];
                }
                else
                {
                    res++;
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 19928
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] v1=new int[n/2];
    int[] v2=new int[n/2];
    for(int i=0;i<n/2;i++){
      v1[i]=sc.nextInt();
      v2[i]=sc.nextInt();
    }
    Arrays.sort(v1);
    int start=0;
    ArrayList<Pair> p1=new ArrayList<Pair>();
    for(int i=0;i<n/2;i++){
      if(i+1==n/2||v1[i]!=v1[i+1]){
        int v=v1[i];
        int m=i-start+1;
        p1.add(new Pair(v,m));
        start=i+1;
      }
    }
    p1.sort((s1,s2)->s2.m-s1.m);
    p1.add(new Pair(-1,0));
//    System.out.println(p1);
    Arrays.sort(v2);
    start=0;
    ArrayList<Pair> p2=new ArrayList<Pair>();
    for(int i=0;i<n/2;i++){
      if(i+1==n/2||v2[i]!=v2[i+1]){
        int v=v2[i];
        int m=i-start+1;
        p2.add(new Pair(v,m));
        start=i+1;
      }
    }
    p2.sort((s1,s2)->s2.m-s1.m);
    p2.add(new Pair(-2,0));
//    System.out.println(p2);
    if(p1.get(0).v!=p2.get(0).v){
      System.out.println(n-p1.get(0).m-p2.get(0).m);
    }else{
      System.out.println(
        Math.min(
          n-p1.get(0).m-p2.get(1).m,
          n-p1.get(1).m-p2.get(0).m
        )
      );
    }
  }
  static class Pair{
    int v;
    int m;
    Pair(int a,int b){
      v=a;
      m=b;
    }
    public String toString(){
      return "["+String.valueOf(v)+","+String.valueOf(m)+"]";
    }
  }
}

Measured memory_bytes: 51988
def main(argv)
  m = [0] * 2
  d = [0] * 2

  2.times do |i|
    (m[i], d[i]) = gets.chomp.split(' ').map(&:to_i)
  end

  if (m[0] < m[1]) and (d[0] > d[1]) then
    puts 1.to_s
  else
    puts 0.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,K = MI()
A = LI()

print((N-1+K-2)//(K-1))


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
vector<vector<int>> edges;
ll dp[100010][2];

void dfs(int i,int p = -1) {
    for (int j : edges[i]) if (j != p) {
        dfs(j,i);
        (dp[i][0] *= (dp[j][0]+dp[j][1])%mod) %= mod;
        (dp[i][1] *= dp[j][0]) %= mod;
    }
}

int main() {
    cin >> n;
    edges.resize(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for (int i = 0;i < n;++i) dp[i][0] = dp[i][1] = 1;
    dfs(0);
    cout << (dp[0][0]+dp[0][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
vector<int> nei[100005];
bool vis[100005];
int num[2];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		nei[x].push_back(y);nei[y].push_back(x);
	}
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	vis[0]=1;
	q.push(make_pair(n-1,1));
	vis[n-1]=1;
	int res;
	while(!q.empty())
	{
		pair<int,int> tmp=q.front();
		q.pop();
		for(int i=0;i<nei[tmp.first].size();i++)
		{
			if(vis[nei[tmp.first][i]]) continue;
			q.push(make_pair(nei[tmp.first][i],tmp.second));
			vis[nei[tmp.first][i]]=1;
//			par[nei[tmp.first][i]]=bing(x);
			num[tmp.second]++;
		}
	}
	if(num[0]>num[1]) cout<<"Fennec"; else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 6016
def main():
	import sys
	input = sys.stdin.readline
	N, K = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ans = sum(p[:K])
	car = ans
	for i in range(N-K):
		car = car + p[i+K] - p[i]
		ans = max(ans, car)
	print((ans + K) / 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24404
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = str(n)
sn = 0
for i in range(len(s)):
    sn += int(str(s[i]))
if n % sn == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5140
#include <iostream>

using namespace std;

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

    long long n, a[5];
    cin >> n;
    for (int i = 0; i < 5; i++)
        cin >> a[i];

    long long min = a[0];
    for (int i = 0; i < 5; i++)
        if (a[i] < min)
            min = a[i];

    const long long time = n / min + (n % min != 0) + 4;

    cout << time << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> B(N-1), A(N);
    rep(0, N-1) cin >> B[i];
    rep(0, N){
        if(i==0)
            A[i] = B[0];
        else if(i == N-1)
            A[i] = B[N - 2];
        else 
            A[i] = min(B[i - 1], B[i]);  
    }
    int n = 0;
    rep(0, N) n += A[i];
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
int main(){
    ll m;
    cin >> m;
  m *= 2;
    ll copy = m;
    map<ll,ll> odd;
    ll even = 1;
    for(int i = 2;i <= sqrt(copy);i++){
        while(m % i == 0){
            if(i == 2)even *= 2;
            else odd[i]++;
            m /= i;
        }
    }
    if(m > 1)odd[m]++;
    ll k = odd.size();
    ll res = pow(10,18);
    for(int i = 0; i < (1<<k); i++){
      ll a = even;
      ll b = 1;
      ll it = 0;
      for(auto item:odd){
          if(i & (1<<it))a *= pow(item.first,item.second);
          else b *= pow(item.first,item.second);
          it++;
      }
      ll x,y;
      extGCD(a,-1*b,x,y);
      if(a * x > 1)res = min(res,a * x);
      extGCD(b,-1*a,x,y);
      if(b * x > 1)res = min(res,b * x);
    }
    if(res == pow(10,18))res = copy;
    else res++;
    cout << res - 1 << endl;
}

Measured memory_bytes: 4056
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int A,B;
    int cnt=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++){
        if((i/10000)==(i%10)){
            if((i/1000)%10==(i/10)%10){
                cnt++;
            }else{
                ;
            }
        }else{
            ;
        }
    }
    printf("%d",cnt);
}


Measured memory_bytes: 1736
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	ll y;
	if (b - 1 <= n) {
		y = b - 1;
	}
	else {
		y = n % b;
	}
	
	ll ans = ll(double(a) *( double(y) / double(b))) - ll(a*(y/b));
	cout << ans;
	//cout << y << endl;
	//cout << ll(double(a) * (double(y) / double(b))) << endl;
	//cout << ll(a * (y / b)) << endl;
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<double, int> d_i;

const int MOD = 1e9 + 7;
const int INF = INT_MAX / 10;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N, x; cin >> N >> x;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	int ma = 0;
	rep(i, N) ma = max(ma, a[i]);
	int d = 0;
	rep(i, N) d = gcd(d, a[i]);
	if (x <= ma && x % d == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int table[3][3];
bool used[3][3];

int main() {
    rep(i,3) rep(j,3) cin >> table[i][j];
    int N; cin >> N;
    rep(i,N) {
        int b; cin >> b;
        rep(i,3) rep(j,3) if(table[i][j] == b) used[i][j] = true;
    }
    bool ans = false;
    rep(i,3) {
        bool ok = true;
        rep(j,3) if(!used[i][j]) ok = false;
        if(ok) ans = true;
    }
    rep(j,3) {
        bool ok = true;
        rep(i,3) if(!used[i][j]) ok = false;
        if(ok) ans = true;
    }
    if(used[0][0]&&used[1][1]&&used[2][2]) ans = true;
    if(used[0][2]&&used[1][1]&&used[2][0]) ans = true;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	static final long MODULO = 1_000_000_000 + 7;
	static long[] pow10 = new long[50];
	static int mask;

	public static void main(String[] args) {
		pow10[0] = 1;
		for (int i = 1; i < pow10.length; ++i) {
			pow10[i] = 10 * pow10[i - 1] % MODULO;
		}

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		mask = (1 << (x + y + z)) - 1;
		solve(n, x, y, z);
	}

	static void solve(int n, int x, int y, int z) {
		long[][] dp = new long[n + 1][1 << (x + y + z)];
		dp[0][0] = 1;
		for (int i = 1; i <= n; ++i) {
			for (int s = 0; s < 1 << (x + y + z); ++s) {
				for (int ne = 1; ne <= 10; ++ne) {
					int ns = (s << ne | 1 << (ne - 1)) & mask;
					if (f(ns, x, y, z))
						continue;
					dp[i][ns] = (dp[i][ns] + dp[i - 1][s]) % MODULO;
				}
			}
		}
		long ans = pow10[n];
		for (long v : dp[n]) {
			ans = (ans - v + MODULO) % MODULO;
		}
		System.out.println(ans);
	}

	static boolean f(int s, int x, int y, int z) {
		boolean ret = true;
		ret &= ((s >> (z - 1)) & 1) > 0;
		ret &= ((s >> (y + z - 1)) & 1) > 0;
		ret &= ((s >> (x + y + z - 1)) & 1) > 0;
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 68436
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = collections.deque(input())
Q = int(input())
for _ in range(Q):
  I = input()
  if len(I) == 1:
    count += 1
  else:
    F = int(I[2])
    C = I[4]
    k = (count + F ) % 2
    if k == 0:
      s.append(C)
    else:
      s.appendleft(C)
if count % 2:
  s.reverse()
for i in s:
  print(i,end = "")
print()

Measured memory_bytes: 91612
def is_puts?(num)
  return true if num % 3 == 0 || num % 10 == 3
  while num > 0
    num /= 10
    return true if num % 10 == 3
  end
  return false
end
   
n = gets.chomp.to_i
str = ''
(1..n).each do |i|
  if is_puts?(i)
    str << " #{i}"
  end
end
puts str

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

signed main(){
    string S;
    cin >> S;
    
    for(int i=0;i<S.length();i++){
        cout << "x";
    }
    
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)

Measured memory_bytes: 32644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() 
{
	string str;
	cin >> str;
	int n = str.length();
	reverse(str.begin(), str.end());
	str = "0" + str;
	ll two[n + 1] = {1}, three[n + 1] = {1};
	for (int i = 1; i <= n; i++)
	{
		two[i] = (two[i - 1] * 2) % mod;
		three[i] = (three[i - 1] * 3) % mod;
	}
	
	ll ans = 0, bits = 0;
	for (int i = n + 1; i >= 2; i--)
	{
		if (i <= n && str[i] == '1') bits++;
		if (str[i - 1] == '1') ans = (ans + two[bits]*three[i - 2]) % mod;
	}
	
	if (str[1] == '1') bits++;
	cout << (ans + two[bits]) % mod;
}

Measured memory_bytes: 2044
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n,s = readints()
a = readints()

mod = 998244353

dp = [[0]*(s+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(1,n+1):
    x = a[i-1]
    for j in range(s+1):
        dp[i][j] = dp[i-1][j]*2
        if 0<=j-x:
            dp[i][j] += dp[i-1][j-x]
        dp[i][j]%=mod


print(dp[n][s])




Measured memory_bytes: 132668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
const ll MOD=1e9+7;
bool prime(ll n){
    for(ll i=2;i*i<=n;i++)if(n%i==0)return 0;
    return 1;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll val = 3;
    for(ll i=0;i<n;i++,val++){
        while(!prime(val) || val%5!=1)val++;
        cout<<val<<" ";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
using namespace std;

const char UP    = 'N';
const char DOWN  = 'S';
const char RIGHT = 'E';
const char LEFT  = 'W';

class Dice{
public:
    int und;
    int over;
    int up;
    int down;
    int right;
    int left;

    Dice(int arr[]){
        und   = arr[5];
        over  = arr[0];
        up    = arr[4];
        down  = arr[1];
        right = arr[2];
        left  = arr[3];
    }

    void upd(int& a, int& b, int& c, int& d){
        int tmp;
        tmp = a;
        a = b;
        b = c;
        c = d;
        d = tmp;
    }

    void move(char order){
        if (order == UP){
            upd(und, up, over, down);
        }else if(order == DOWN){
            upd(und, down, over, up);
        }else if(order == RIGHT){
            upd(und, right, over, left);
        }else{
            upd(und, left, over, right);
        }
    }

    void act(int len, ...){
        va_list args;
        va_start(args, len);
        char order;
        for(int i = 0; i < len; i ++){
            order = va_arg(args, int);
            move(order);
        }
        va_end(args);
    }
};

int judge(Dice d1, Dice d2){
    int res = (
        d1.und == d2.und &&
        d1.over == d2.over &&
        d1.up == d2.up &&
        d1.down == d2.down &&
        d1.right == d2.right &&
        d1.left == d2.left
    );
    return res;
}

int run(Dice d1, Dice d2){
    for(int i = 0; i < 4; i ++){
        for(int j = 0; j < 4; j ++){
            if (judge(d1, d2)){
                return 1;
            }
            d1.move(RIGHT);
        }
        d1.move(DOWN);
    }
    d1.act(2, RIGHT, DOWN);
    for(int j = 0; j < 4; j ++){
        if (judge(d1, d2)){
            return 1;
        }
        d1.move(RIGHT);
    }
    d1.act(2, DOWN, DOWN);
    for(int j = 0; j < 4; j ++){
        if (judge(d1, d2)){
            return 1;
        }
        d1.move(RIGHT);
    }
    return 0;
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int a[N][6];
    for(int i = 0; i < N; i ++){
        for(auto &j: a[i]){
            cin >> j;
        }
    }
    for(int i = 0; i < N; i ++){
        for(int j = i + 1; j < N; j ++){
            Dice d1(a[i]), d2(a[j]);
            if (run(d1, d2) == 1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i==3)cout<<s[i]<<" ";
        else cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int a, b, c; cin >> a >> b >> c;
	set<int> j;
	j.insert(a); j.insert(b); j.insert(c);
	cout << j.size() << endl;
	return 0;
}

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

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

  long long int result1,result2,result3;
  result1 = (A*N)/B;
  //result2 = (A*N)/B-A*(N/B);
  result3 = (A*(B-1))/B;

  cout << min(result1,result3) << endl;

}


Measured memory_bytes: 3640
/*
 * Author:heroming
 * File:heroming.cpp
 * Time:2017/01/07 07:58:48
 */
#include <vector>
#include <list>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <unordered_map>
using namespace std;

#define px first
#define py second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define clr(v, e) memset(v, e, sizeof(v))
#define rep(it, v) for (auto it : v)
#define forn(i, n) for (int i = 0; i < (n); ++ i)
#define rforn(i, n) for (int i = (n) - 1; i >= 0; -- i)
#define form(i, a, b) for (int i = (a); i <= (b); ++ i)
#define rform(i, a, b) for (int i = (b); i >= (a); -- i)
#define forv(i, v) for (int i = 0; i < sz(v); ++ i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++ it)

typedef long long lint;
typedef vector<int> vint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef vector<lint> vlint;
typedef vector<pint> vpint;

int main() {
    string s;
    while (cin >> s) {
        forv (i, s) {
            if (s[i] == ',') s[i] = ' ';
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce


def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    _max = max(A)
    g = reduce(gcd, A)

    if K <= _max and K % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 20468
iN , iK = [int(x) for x in input().split()]

if iK % 2 == 0 :
    iFK = int(iK / 2)
    # iFK の奇数だけの組と偶数だけの組
    iULimit = int(iN /iFK)
    if iULimit % 2 == 0:
        print (int(iULimit / 2 ) ** 3 * 2 )
    else:
        print( int((iULimit + 1 )/ 2) ** 3 + int((iULimit - 1)/2) ** 3)
else:
    #iKの倍数だけの組み合わせ
    iULimit = int( iN / iK )
    print(iULimit ** 3)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

inf = 1e10
def gcd(a, b):
    while b: a, b = b, a%b
    return a

N, Ma, Mb = map(int, raw_input().split())
abc = [map(int, raw_input().split()) for i in xrange(N)]

dp = [[0]*405 for i in xrange(405)]

for a, b, c in abc:
    for i in xrange(404-a, -1, -1):
        for j in xrange(404-b, -1, -1):
            if dp[i][j]:
                if dp[i + a][j + b] == 0: dp[i + a][j + b] = dp[i][j] + c
                else: dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)
    if dp[a][b] == 0: dp[a][b] = c
    else: dp[a][b] = min(dp[a][b], c)

ans = inf
for i in xrange(1, 405):
    for j in xrange(1, 405):
        g = gcd(i, j)
        if i/g == Ma and j/g == Mb and dp[i][j]:
            ans = min(ans, dp[i][j])

print ans if ans < inf else -1


Measured memory_bytes: 5668
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,minn=99999999,maxn = -1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x ;
		scanf("%d",&x);
		maxn = max(maxn,x);
		minn = min(minn,x);
		
	}
	printf("%d",maxn-minn);
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn main() {
    let s: String = read();
    let k: u64 = read();
    let one_count: usize = s.chars().take_while(|x|*x == '1').count();
    if k <= (one_count as u64)  {
        println!("1");
    } else {
        let not_one: char = s.chars().skip_while(|x|*x == '1').next().unwrap();
        println!("{}", not_one);
    }
}



Measured memory_bytes: 2172
n = gets.to_i
a = gets.split.map(&:to_i)

x = Array.new n
y = Array.new n

x[0] = a[0]
y[-1] = a[-1]
(1..n-1).each{|i| x[i] = a[i].gcd x[i-1]}
(0..n-2).reverse_each{|i|y[i] = a[i].gcd y[i+1]}

ret = [x[n-2], y[1]].max
(1..n-2).each{|i|ret = [ret, x[i-1].gcd(y[i+1])].max}

p ret


Measured memory_bytes: 13580
s = input()
k = int(input())
onecnt = 0
for i in range(len(s)):
  if s[i] == "1":
    onecnt += 1
  else:
    break
    
if onecnt == 0:
  print(s[0])
  exit()
if onecnt >= k:
  print(1)
  exit()
else:
  print(s[onecnt])

Measured memory_bytes: 3060
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int A, B, M;
  cin >> A >> B >> M;
  vi a(A), b(B);
  cin >> a >> b;

  int ans = INF;
  rep(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    chmin(ans, a[x - 1] + b[y - 1] - c);
  }
  sort(all(a));
  sort(all(b));
  chmin(ans, a[0] + b[0]);
  out(ans);
}

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



int main()
{
	int N;
	
	scanf("%d", &N);

	long double x[N];
	char u[N][4];
	int i, j;
	double sum = 0;

	for (i = 0; i < N; i++) {
		scanf("%Lf%s", &x[i], u[i]);
	}

	for (i = 0; i < N; i++) {
		if (strcmp(u[i], "JPY") == 0) {
			sum += x[i];
		} else {
			sum += (x[i] * 380000.0);
		}
	}

	printf("%f\n", sum);

	return 0;
}


Measured memory_bytes: 128
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    long long highest=0,sum=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(highest<a[i]) highest=a[i];
        else{
            sum+=(highest-a[i]);
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 4040
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    n, x, y = map(int, input().split())
    g = [[] for _ in range(n)]
    for i in range(n-1):
        g[i].append(i+1)
        g[i+1].append(i)
    x -= 1
    y -= 1
    g[x].append(y)
    g[y].append(x)

    d = {}
    for i in range(n):
        d[i] = 0

    for i in range(n):
        q = deque()
        q.append(i)
        visit = [-1]*n
        visit[i] = 0
        while q:
            x = q.popleft()
            for nx in g[x]:
                if visit[nx] == -1:
                    visit[nx] = visit[x]+1
                    q.append(nx)
        for i in range(n):
            d[visit[i]] += 1
    # print(d)
    for k in range(1, n):
        print(d[k]//2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49372