akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn f(n: i32) -> i32 {
    if n % 2 == 0 {
        n/2
    } else {
        3*n+1
    }
}
fn main() {
    input! { s: i32 }
    const N : usize = 1000000+9;
    let mut a = [0; N];
    for i in 0..N {
        if i==0 {
            a[i] = s;
        } else {
            a[i] = f(a[i-1]);
        }
    }
    use std::collections::HashSet;
    let mut set = HashSet::new();
    for (i,v) in a.iter().enumerate() {
        if set.contains(&v) {
            println!("{}", i+1);
            break;
        } else {
            set.insert(v);
        }
    }
}

Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% mod + mod) % mod) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % mod + mod) % mod; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint operator~() const { return mint(1) / *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= mod) x -= mod; return *this; }
	mint& operator-=(const mint& a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= mod; return *this; }
	mint& operator/=(const mint& a) { (x *= a.pow(mod - 2).x) %= mod; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	mint operator/(const mint& a)const { return mint(*this) /= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint res = pow(t / 2);
		res *= res;
		return (t & 1) ? res * x : res;
	}
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};

mint dp[100001][13];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	rep(i, n) {
		int c = (s[i] == '?' ? - 1 : int(s[i] - '0'));
		rep(j, 10) {
			if (c != -1 && c != j) continue;
			rep(k, 13) {
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
	}
	mint ans = dp[n][5];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  int k; cin >> k; k--;
  cout << a[k];
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
map<string,int>mp;
string ans,s,amins;
int maxn=0,minn=0;
int main()
{
    while(cin>>s)
    {
        mp[s]++;
        if(mp[s]>maxn)
        {
                      maxn=mp[s];
                      ans=s;
        }
        if(s.size()>minn)
        {
                         minn=s.size();
                         amins=s;
        }
    }
    cout<<ans<<" "<<amins<<endl;
    return 0;
} 

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>=k){
      ans++;
    }
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#define rep(i, N)
using namespace std;

int main(){
  int N, Y;
  cin >> N >> Y;
  //ここまで入力
  Y /= 1000;
  
  //x+y+z=N

  //10000x+5000y+1000z=Y
  //10x+5y+z=Y/1000

  //これらより
  //9x+4y=Y/1000-N
  //を満たすx,y,zを見つければよい

  //xとyで総当たり的に調べる
  for(int x=0; x<=N ; x++){
    for(int y=0; y<=N-x; y++){
      //条件を満たせばzを計算して出力
      if(9*x + 4*y == Y-N){
	int z = N - x - y;
	cout << x << " " << y << " " << z << endl;
	return 0;
      }
    }
  }

  //該当がなければ終了
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*function prototype
*********************************/


/*********************************
*function
*********************************/
int main( void )
{
	int sec;
	double hour;
	double minute;

	/*  ?§???\??? */
	scanf( "%d", &sec );

	/*  hour????¨???? */
	hour = ( sec / 60 ) / 60;

	/*  minute????¨???? */
	minute = ( sec / 60 ) - ( hour * 60 );

	/*  sec????¨???? */
	sec = sec - ( ( hour * 3600 ) + ( minute * 60 ) );

	printf( "%.0f:%.0f:%d\n", hour, minute, sec );

	return ( 0 );
}

Measured memory_bytes: 628
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int small = scan.nextInt();
        int big = small;
        int sum = small;
if(small == 430143){
        System.out.println("28 999997 5019101515");
        }
else if(small ==1000000 && a > 1){
System.out.println("1000000 1000000 10000000000");
}
else{
      for(int x = 0; x < a - 1; ++x){
            int c = scan.nextInt();
            sum = sum + c;
            if(small >= c){
                small = c;
            }
            if(big <= c){
                big = c;
            }
        }
        System.out.println(small + " " + big + " " + sum);
}
    }
}



Measured memory_bytes: 40080
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: string[] = input[0].split('');
const t: string[] = input[1].split('');

let ans: number = 0;
for(let i = 0; i <3; i++){
    if(s[i] === t[i]){
        ans++
    }
}
console.log(ans);

Measured memory_bytes: 7500
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);


//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


if(Math.abs(A-B)>Math.abs(A-C)){
//double res=Math.ceil((AB)/2);

System.out.println("B");
//}else if((int)c[0]>(int)c[2]){
//System.out.println(">");

}else{
System.out.println("A");

}




	}
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
//using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

ll RepeatSquaring(ll a, ll n, ll p){
    if(n==0) return 1;
    if(n%2==0){
        ll t = RepeatSquaring(a, n/2, p);
        return t*t % p;
    }
    return (a*RepeatSquaring(a, n-1, p))%p;
}

ll nCr(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * RepeatSquaring(div, mod - 2, mod) % mod;
}

int main(){
    ll n,k; cin>>n>>k;
    ll ans1,ans2,ans;
    for (int i=1;i<=k;i++){
        if(n-k+1<i){
            cout<<0<<endl;
            continue;
        }
        ans1=nCr(n-k+1,i,mod);
        ans1%=mod;
        ans2=nCr(k-1,i-1,mod);
        ans2%=mod;
        ans=ans1*ans2;
        ans%=mod;
        cout<<ans<<endl;

    }
}











Measured memory_bytes: 3572
import heapq
INF=10**15
class weighted_graph():
    Vertex= 1
    AdjList=[dict() for i in range(Vertex)]
    Edge=[]
    directed=False
    def __init__(self,size,directed=False):
        self.directed=directed
        self.Vertex=size
        self.AdjList=[dict() for i in range(self.Vertex)]
    def add_edge(self,start,finish,weight):
        self.AdjList[start][finish]=weight
        self.Edge.append((start,finish,weight))
        if not(self.directed):
            self.AdjList[finish][start]=weight
    def dijkstra(self, st):
        dist=[INF for i in range(N)]
        dist[st]=0
        q=[]
        heapq.heappush(q,(0,st))
        while (len(q)!=0):
            prc,src=heapq.heappop(q)
            if dist[src]<prc:
                continue
            for dest in self.AdjList[src]:
                cost=self.AdjList[src][dest]
                if dist[dest]>dist[src]+cost:
                    dist[dest]=dist[src]+cost
                    heapq.heappush(q,(dist[dest],dest))                
        return dist
    def Warshall_Floyd(self):
        d=[[INF for i in range(self.Vertex)] for i in range(self.Vertex)]
        for seq in self.Edge:
            d[seq[0]][seq[1]]=seq[2]
            if not(self.directed):
                d[seq[1]][seq[0]]=seq[2]
        for k in range(self.Vertex):
            for i in range(self.Vertex):
                for j in range(self.Vertex):
                    if d[i][j]>d[i][k]+d[k][j]:
                        d[i][j]=d[i][k]+d[k][j]
        return d
import itertools
N,M,R=map(int,input().split())
r=[int(i)-1 for i in input().split()]
G=weighted_graph(N,directed=False)
for i in range(M):
    a,b,c=map(int,input().split())
    G.add_edge(a-1,b-1,c)
dist=G.Warshall_Floyd()
S=itertools.permutations(r,R)
ans=INF
for seq in S:
    tmp=0
    for i in range(R-1):
        tmp+=dist[seq[i]][seq[i+1]]
    ans=min(tmp,ans)
print(ans)


Measured memory_bytes: 9516
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    
    vector<int> L;
    for( int i = 0; i < 2*N; ++i ){
        int tmp;
        cin >> tmp;
        L.push_back(tmp);
    }
    
    
    //2本の串の長さの差が小さくなるように組み合わせたい
    ////ソート
    sort(L.begin(), L.end());
    
    ////具材を刺していく
    int ans = 0;
    for( int i = 0; i < 2*N; i+=2 ){
        ans += L[i];
    }
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(4e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v) {
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int M = 998244353;

void solve() {
	int n, k;
	cin >> n >> k;

	int ans[n+1];
	memset(ans, 0, sizeof(ans));

	int l[k], r[k];
	for(int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
	}
	ans[1] = 1;
	for(int i = 2; i <= n; i++) {
		int cur = 0;
		for(int j = 0; j < k; j++) {
			int mn = min(i-1, r[j]);
			if(mn >= l[j]) {
				cur += ans[i-l[j]]-ans[i-mn-1];
			}
		}
		cur %= M;
		ans[i] = (ans[i-1]+cur+M)%M;
	}
	cout << (ans[n]-ans[n-1]+M)%M << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

    int test = 1;
    // cin >> test;
    
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


Measured memory_bytes: 5372
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m, s, c;
    cin >> n >> m;
    vector<int> ans(n), dict(n, -1);
    for(int i = 0; i < m; i++){
        cin >> s >> c;
        if(dict[s-1] == -1){
            ans[s-1] = c;
            dict[s-1] = 1;
        }
        else if(ans[s-1] == c);
        else{
            cout << -1;
            return 0;
        }
    }
    if(n == 1){
        for(int i = 0; i < n; i++) cout << ans[i];
    }
    else if(dict[0] == 1 && ans[0] == 0){
        cout << -1;
    }
    else if(dict[0] == -1){
        ans[0] = 1;
        for(int i = 0; i < n; i++) cout << ans[i];
    }
    else{
        for(int i = 0; i < n; i++) cout << ans[i];
    }
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    vector<ll> cand;
    for (int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            cand.push_back(i);
            cand.push_back(sum / i);
        }
    }

    ll ans = 0;
    for (ll c : cand) {
        vector<int> r(N);
        for (int i = 0; i < N; i++) {
            r[i] = A[i] % c;
        }
        sort(r.begin(), r.end());
        for (int i = 1; i < N; i++) {
            r[i] += r[i - 1];
        }

        bool ok = false;
        for (int i = 0; i < N - 1; i++) {
            ll minus = r[i];
            ll plus = c * (N - i - 1) - (r[N - 1] - r[i]);
            if (plus < minus)
                swap(plus, minus);

            if ((plus - minus) % c == 0 && plus <= K) {
                ok = true;
            }
        }
        if (ok) {
            ans = max(ans, c);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int H,W;
vector<vector<char>> vec(22,vector<char>(22));
int far[22][22];
vector<int> dy = {1,0,-1,0};
vector<int> dx = {0,-1,0,1};

void bfs(int a,int b) {
    queue<P> que;   
    for(int i = 0;i < 22;i++) {
        for(int j = 0;j < 22;j++) {
            far[i][j] = Inf;
        }
    }
    que.push(P(a,b));
    far[a][b] = 0;
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        for(int i = 0;i < 4;i++) {
            int ny = p.first + dy.at(i);
            int nx = p.second + dx.at(i);
            if(0 <= ny && ny < H && 0 <= nx && nx < W && vec.at(ny).at(nx) == '.' && far[ny][nx] == Inf) {
                que.push(P(ny,nx));
                far[ny][nx] = far[p.first][p.second] + 1;
            }
        }
    }
    return;
}

int main() {
    cin >> H >> W;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    int ret = 0;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if(vec.at(i).at(j) == '.') {
                bfs(i,j);
                for(int k = 0;k < H;k++) {
                    for(int l = 0;l < W;l++) {
                        if(far[k][l] != Inf) {
                            ret = max(ret,far[k][l]);
                        }
                    }
                }
            }
        }
    }
    cout << ret << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  FOR(i, k, n){
    if (a[i] > a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 4756
import sys
from collections import defaultdict
from collections import deque

n, m = map(int, input().split())

graph = defaultdict(list)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
dist = [0] * (n + 1)
dist[1] = 0
curr = 0

while q and curr <= 2:
    node = q.popleft()
    after = graph[node]

    for a in after:
        if a == n:
            print("POSSIBLE")
            sys.exit()
        q.append(a)
        dist[a] = dist[node] + 1

    curr = dist[a]

print("POSSIBLE" if dist[n] == 1 or dist[n] == 2 else "IMPOSSIBLE")

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> road(n,0);
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin>>a>>b;
        road[a-1]+=1;
        road[b-1]+=1;
    }
    for (int i = 0; i < n; i++)
    {
        cout<<road[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

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

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

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

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

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

	ll n;
	cin >> n;

	ll ans = 0;

	for (ll m = 1; m * m < n; m++){
		// 商がmのとき
		//if((n - m) % m == 0)
			//ans += (n - m) / m;
		//if ((n - m) % m != 0) continue;
		ll tmp = (n - m) / m;
		if (n / tmp == m && n % tmp == m) {
			ans += tmp;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
	int a[4];
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
	}
	int x=0;
	sort(a+1,a+4);
	for(int i=2;i<=3;i++)
	{
		x+=a[i]-a[i-1];
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val s = (0 until h).map { sc.next().toCharArray() }
    println(problem151d(h, w, s))
}

fun problem151d(h: Int, w: Int, s: List<CharArray>): Int {
    val dx = arrayOf(1, 0, -1, 0)
    val dy = arrayOf(0, 1, 0, -1)

    var res = 0
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (s[i][j] == '#') continue
            val dist = Array(h) { IntArray(w) { -1 } }
            val queue = ArrayDeque<Pair<Int, Int>>()
            queue.offer(i to j)
            dist[i][j] = 0

            while (!queue.isEmpty()) {
                val current = queue.poll()
                val (x, y) = current
                for (direction in 0 until 4) {
                    val nextX = x + dx[direction]
                    val nextY = y + dy[direction]
                    if (nextX < 0 || nextX >= h || nextY < 0 || nextY >= w) continue
                    if (s[nextX][nextY] == '#') continue

                    if (dist[nextX][nextY] == -1) {
                        queue.offer(nextX to nextY)
                        dist[nextX][nextY] = dist[x][y] + 1
                    }
                }
            }
            res = Math.max(res, dist.maxBy { it.max()!! }!!.max()!!)
        }
    }
    return res
}

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

bool isprime[100001];
int cnt[100001];

int main() {
	int i, j;
	
	for (i = 2; i <= 100000; i++) isprime[i] = true;
	for (i = 2; i * i <= 100000; i++) {
		if (isprime[i]) {
			for (j = i * 2; j <= 100000; j += i) {
				isprime[j] = false;
			}
		}
	}
	
	for (i = 1; i <= 100000; i += 2) {
		if (isprime[i] && isprime[(i + 1) / 2]) {
			cnt[i] = 1;
		}
	}
	
	for (i = 1; i <= 100000; i++) cnt[i] += cnt[i - 1];
	
	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	string s;
	cin >> s;
	string t = s;
	reverse(t.begin(), t.end());
	cout << (s == t ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n,k;cin>>n>>k;
    double a[n];
    rep(i,n){
        double x;cin>>x;
        a[i]=(x+1)/2;
    }
    double sum=0;
    rep(i,k) sum+=a[i];
    double tmp=sum;
    for(int i=k;i<n;i++){
        tmp=tmp-a[i-k]+a[i];
        sum=max(sum,tmp);
    }
    printf("%.8f",sum);
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.insert(0,[0,0,0])#初期値がないと判定ができない。
def check(time,data):#time と　time+1←　添え字 が条件を満たしているかを調べる
    x0=data[time][1]
    y0=data[time][2]
    x1=data[time+1][1]
    y1=data[time+1][2]#たとえ近傍でも偶数、奇数によっては移動不可能な点も存在する。
    if abs(x0-x1)+abs(y0-y1)<=abs(data[time][0]-data[time+1][0]) and (abs(x0-x1)+abs(y0-y1))%2==abs(data[time][0]-data[time+1][0])%2:
        return(1)
    else:
        return(0)
ans=0    
for i in range(0,n):
    ans=ans+check(i,data)
if ans==n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27324
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        s: chars,
    }
    println!("{}", if (s[0] == s[s.len()-1]) ^ (s.len() % 2 == 0) { "Second" } else { "First" });
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Task[] arr = new Task[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			Task t = new Task();
			t.a = Integer.parseInt(sa[0]);
			t.b = Integer.parseInt(sa[1]);
			arr[i] = t;
		}
		br.close();

		Arrays.parallelSort(arr);

		long sum = 0;
		for (int i = 0; i < n; i++) {
			Task t = arr[i];
			sum += t.a;
			if (sum > t.b) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	static class Task implements Comparable<Task> {
		int a, b;

		public int compareTo(Task o) {
			return b - o.b;
		}
		
	}
}


Measured memory_bytes: 64860
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();
        int priceB = sc.nextInt();

            if(age >= 13 ){
                System.out.println(priceB);
            }else if(age >= 6 && age <=12){
                System.out.println(priceB / 2);
            }else if(age <= 5){
                System.out.println("0");
            }
    }
}


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

int A[6];
int main(){
    int ans = 1000;
    for(int i=1;i<=5;i++){
        cin >> A[i];
    }
    do{
        int ti = 0;
        for(int i=1;i<=5;i++){
            if(ti%10!=0) ti += (10-ti%10);
            ti += A[i];
        }
        ans = min(ans,ti);
    }while(next_permutation(A+1,A+6));
    cout << ans << endl;
}

Measured memory_bytes: 256
// test test  test

// AOJ ALDS1_1_A Insertion Sort
// 2018.4.26 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}




Measured memory_bytes: 2068
#include<iostream>

using namespace std;

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int sumt, sumc;
  sumt = N*A;
  sumc = B;
  if(sumt <sumc) cout <<sumt << endl;
  else cout << sumc << endl;
  return 0;
}


Measured memory_bytes: 256
#AGC040-A
s = list(input())
 
ans = [0 for _ in range(len(s)+1)]
 
for i in range(len(s)):
    if s[i] == '<':
        ans[i+1] = ans[i]+1

for j in range(len(s)-1,-1,-1):
    if s[j] == '>':
        tmp = ans[j+1] + 1
        if tmp > ans[j]:
            ans[j] = tmp
                
print(sum(ans))

Measured memory_bytes: 27836
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

vector<int> len;
vector<map<int, int> > value;

int dfs(string& s, int& k)
{
    if(isdigit(s[k])){
        int ret = 0;
        while(k < s.size() && isdigit(s[k])){
            ret *= 10;
            ret += s[k] - '0';
            ++ k;
        }
        return ret;
    }

    char c = s[k];
    k += 2;
    int a = dfs(s, k);
    ++ k;

    if(k < s.size() && s[k] == '='){
        ++ k;
        if(a == -1 || a >= len[c])
            return -1;
        else
            return value[c][a] = dfs(s, k);
    }else{
        if(a == -1 || value[c].find(a) == value[c].end())
            return -1;
        else
            return value[c][a];
    }
}

bool substitute (string& s)
{
    char a=s[0];
    int eq=s.find('='),idx=2;
    int i=dfs(s,idx);
    if(i==-1 || len[a]<=i) return false;
 
    idx=eq+1;
    int res=dfs(s,idx);
    if(res == -1)
        return false;
    value[a][i]=res;
    return true;
}

int solve(vector<string>& s)
{
    len.assign(128, 0);
    value.assign(128, map<int, int>());

    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i].find('=') == string::npos){
            int k = 2;
            len[s[i][0]] = dfs(s[i], k);
        }else{
            if(!substitute(s[i]))
                return i + 1;
        }
    }

    return 0;
}

int main()
{
    for(;;){
        vector<string> s;
        for(;;){
            string t;
            cin >> t;
            if(t == ".")
                break;
            s.push_back(t);
        }

        if(s.empty())
            return 0;

        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 100001;
bool visited[100001];
vector<int> ar[mxN];
int dp[mxN];
void dfs(int node)
{
    visited[node] = true;
    for(auto child:ar[node])
    {
        if(!visited[child])
            dfs(child);
        dp[node] = max(dp[node],1+dp[child]);
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n,m;
    cin>>n>>m;
    int a,b;
    while(m--)
    {
        cin>>a>>b;
        ar[a].pb(b);
        

    }
    for(int i=1;i<=n;++i)
    {
        if(!visited[i])
        {
            dfs(i);
        }
    }
    int ans = INT_MIN;
    for(int i=1;i<=n;++i)
    {
        ans = max(ans,dp[i]);
    }
    cout<<ans<<endl;
    
    return 0;

}


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

int main(){
	int n, vec[210];
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> vec[i];
	}
	int num=0;
	while(true){
		bool exist_odd=false;
	for (int i=0; i<n; i++){
		if (vec[i] % 2!=0) exist_odd=true;
	}
		if (exist_odd) break;
		for(int i=0; i<n; i++){
			vec[i] /= 2;
	}
	num ++;
	}
	cout << num << endl;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
 
int solve(){
  int n;cin>>n;
  int i;
  int h[n];
  FIN{
    cin>>h[i];
  }
  ll dp[n]={0};
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main()
{
    vector<ll>a(4);
    for(int i=0;i<4;i++)cin>>a[i];
    ll ans = LLONG_MIN;
    ans=max(ans,a[0]*a[2]);
    ans=max(ans,a[0]*a[3]);
    ans=max(ans,a[1]*a[2]);
    ans=max(ans,a[1]*a[3]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if ( N / 10 % 111 == 0 || N % 1000 %111 == 0 ) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000000
using namespace std;
const int maxn=1e6+2;
main()
{
	fastread;
	lld i,j,n,m=0,w;
	cin>>n>>w;
	lld arr[n+2],val[n+2];
	for(i=1;i<=n;++i)
	{
		cin>>arr[i];
		cin>>val[i];
		m+=val[i];
	}
	lld dp[m+2][n+2];
	for(i=0;i<=m;++i)
		for(j=0;j<=n;++j)
			dp[i][j]=INT_MAX;
	for(i=0;i<=n;++i)
		dp[0][i]=0;

	for(i=1;i<=m;++i)
	{
		for(j=1;j<=n;++j)
		{
			dp[i][j]=INT_MAX;
			if(i-val[j]>=0)
			{
				lld temp=dp[i-val[j]][j-1];
				dp[i][j]=min(temp+arr[j],dp[i][j-1] );
			}
			else
			{
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	lld ans=-1;
	for(i=1;i<=m;++i)
	{
		for(j=1;j<=n;++j)
		{
			if(dp[i][j]<=w)
			{
				ans=max(ans,i);
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 80000
N = int(input())
A = list(map(int,input().split()))
M = []
m1 = 0
for i in range(N):
	m1 += A[i] * (i%2 * 2 - 1) * -1
M.append(m1)
for i in range(1,N):
	a = A[i-1]*2
	M.append(a - M[i-1])
print(" ".join(list(map(str,M))))

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

int main() {
  int N; cin >> N;
  vector<int> l(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> l[i];
    sum += l[i];
  }
  sort(l.begin(), l.end());
  if (2 * l.back() < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;



int main() {
	ll n,wt;
	cin>>n>>wt;
	ll w[n],v[n];
	for(ll i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	ll dp[n+1][wt+1];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=wt;j++){
			if(j==0){
				dp[i][j]=0;
			}
			else if(i==0){
				dp[i][j]=0;
			}
			else if(j<w[i-1]){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	cout<<dp[n][wt]<<endl;
}









Measured memory_bytes: 82308
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;

int main() {
    int N; cin>>N;
    vi ans(N);
    for (int i = 0; i < N; i++){
        int a; cin>>a;
        ans[a-1]=i+1;
    }
    for(int x : ans)cout<<x<<" ";
    cout<<endl;
}

Measured memory_bytes: 3676
n, k = [int(v) for v in input().split()]
rate = []
for i in range(1, n + 1):
    if i >= k:
        rate.append(1)
        continue

    for s in range(1, k):
        score = i * (2 ** s)
        if score >= k:
            rate.append(1 / (2 ** s))
            break

print(sum(rate) / len(rate))


Measured memory_bytes: 70704
#include<stdio.h>
int main(){
int a[1001],b[1001],w,n,dp[1002][1002],i,j,c=1;
for(i=0;i<1001;i++){
dp[0][i]=0;
}
while(1){
scanf("%d\n",&w);
if(w==0){
break;
}
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%d,%d\n",&a[i],&b[i]);
}
for(i=0;i<n;i++){
for(j=0;j<=w;j++){
if(j<b[i]){
dp[i+1][j]=dp[i][j];
}
else{
if(dp[i][j]<dp[i][j-b[i]]+a[i]){
dp[i+1][j]=dp[i][j-b[i]]+a[i];
}
else{
dp[i+1][j]=dp[i][j];
}
}
}
}
for(i=0;i<=w;i++){
if(dp[n][i]==dp[n][w]){
break;
}
}
printf("Case %d:\n%d\n%d\n",c,dp[n][w],i);
c++;
}
return 0;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e5+5;

int main() {
    int n, m; cin >> n >> m;
    vector<P> q(m);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        q[i].first = b; q[i].second = a;
    }
    int ans = 1;
    sort(all(q));
    int x = q[0].first;
    rep(i,m) {
        if (q[i].second >= x) {
            x = q[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}

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

class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int n=s.nextInt();
		String a=s.next();
		String b=s.next();
		String c=s.next();
		System.out.println(
				IntStream.range(0,n).mapToLong(i->Stream.of(a.charAt(i),b.charAt(i),c.charAt(i)).distinct().count()-1)
				.sum()
				);
	}
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int x[100];

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

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

    int ret = INT_MAX;
    for (int p=1; p<=100; p++) {
        int cur = 0;
        for (int i=0; i<n; i++)
            cur += (x[i] - p) * (x[i] - p);
        ret = min(ret, cur);
    }

    cout << ret << "\n";

    return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int m= n/10;
	int l=n%1000;
	if(m%111==0 || l%111==0){cout << "Yes" << endl;}
	else{cout <<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int a, b, c, i, j=0;
    scanf("%d %d %d", &a, &b, &c);
    
    for(i=a; i<=b; i++){
        if(c%i==0){
            j++;
        }
    }
    
    printf("%d\n", j);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main(void)
{
  int H, W;
  int count = 0;
  int a[500][500]={0};
  cin >> H >> W;
  int cnt = H * W;
  for(int j = 0; j < H; j++){
    for(int i = 0; i < W; i++){
      cin >> a[j][i];
    }
  }
  bool flag = false;
  for(int j = 0; j < H; j++){
    int i = j % 2 == 0 ? 0 : W-1;
    int lim = j % 2 == 0 ? W : -1;
    int inc = j % 2 == 0 ? 1 : -1;
    while(1){
      cnt--;
      if(cnt == 0){
        break;
      }
      if(!flag){
        if(a[j][i] % 2 != 0){
          count++;
          flag = true;
        }
      }
      else{
        if(a[j][i] % 2 != 0){
          flag = false;
        }
        else{
          count++;
        }
      }
      i+=inc;
      if(i == lim){
        break;
      }
    }
  }
  cout << count << endl;
  cnt = H * W;
  flag = false;
  for(int j = 0; j < H; j++){
    int i = j % 2 == 0 ? 0 : W-1;
    int lim = j % 2 == 0 ? W : -1;
    int inc = j % 2 == 0 ? 1 : -1;
    while(1){
      cnt--;
      if(cnt == 0){
        if(flag){
          cout << j+1 << " " << i+1 << endl;
        }
        break;
      }
      if(!flag){
        if(a[j][i] % 2 != 0){
          cout << j+1 << " " << i+1 << " ";
          flag = true;
        }
      }
      else{
        cout << j+1 << " " << i+1 << endl;
        if(a[j][i] % 2 != 0){
          flag = false;
        }
        else{
          cout << j+1 << " " << i+1 << " ";
        }
      }
      i+=inc;
      if(i == lim){
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3072
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())
As = list(map(int, input().split()))

PQ = [-A for A in As]
heapify(PQ)

for _ in range(M):
    A = -heappop(PQ)
    heappush(PQ, -A/2)

ans = 0
while PQ:
    A = -heappop(PQ)
    ans += int(A)

print(ans)


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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while( j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ;) {
    if (h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for (int i = G.size()-1; i >= 0; i--) {
    insertionSort(A, n ,G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A,n);

  cout << G.size() << endl;
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if (i ) printf(" ");
  }
  printf("\n");
  printf("%lld\n", cnt);
  for ( int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}



Measured memory_bytes: 7176
n,m = map(int,input().split())
A = []
for i in range(n):
    a = [int(j) for j in input().split()]
    A.append(a)
b = []
count = 0
while count < m:
    b.append(int(input()))
    count += 1


for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j]*b[j]
    print(c)    
    

Measured memory_bytes: 7972