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

int fl[114][514];
int dx[2][6] = { {-1,-1,-1,0,1,0},{0,-1,0,1,1,1} };
int dy[6] = { -1,0,1,-1,0,1 };
int h, w,ans;

void dfs(int nw, int nh) {//fl[nw][nh]
	for (int i = 0;i < 6;i++) {
		fl[nw][nh] = 5;
		int nx = nh + dx[(nw) % 2][i];
		int ny = nw+ dy[i];

		if (nx >= 0 && nx <h+3 && ny >= 0 && ny <w+3) {
			if (fl[ny][nx] == 1)ans++;
			else if(fl[ny][nx]==0) dfs(ny, nx);
		}
	}
	return ;
}

int main() {
	cin >> h >> w;

	for (int i = 1;i <= w;i++) {
		for (int j = 1;j <= h;j++)cin >> fl[i][j];
	}
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }

int main(){
  ll N,K; cin>>N>>K;
  ll a[N]; CINA(a,N);
  // 桁DP (上からx桁目までが (1:不一致 or 0:一致) であるときの最大値)
  ll dp[50][2];
  FILL2(dp,50,2,-1);
  dp[45][0] = 0;
  REPR(d,44){
    // d+1 桁目について
    ll mask = (1LL<<d);
    // bit1の総数
    ll c = 0;
    REP(i,N){
      if(a[i]&mask){ ++c; }
    }
    // 一致パターンからの遷移
    if(dp[d+1][0]>=0){
      if( K & mask ){ // Kの該当桁がbit1
        // bit1(Kの該当桁と同じ)を選択
        chmax(dp[d][0],dp[d+1][0] + mask*(N-c) );        
        // bit0(Kの該当桁と異なる)を選択
        chmax(dp[d][1],dp[d+1][0] + mask*c);        
      }else{ //Kの該当桁がbit0
        // bit0(Kの該当桁と同じ)を選択
        chmax(dp[d][0],dp[d+1][0] + mask*c);
      }
    }
    
    // 不一致なパターンからの遷移
    if(dp[d+1][1]>=0){
      // 自由に遷移
      chmax(dp[d][1], dp[d+1][1]+mask*(N-c) ); 
      chmax(dp[d][1], dp[d+1][1]+mask*c);
    }
  }
  ll ans = max(dp[0][0],dp[0][1]);
  cout << ans << "\n";
  
}


Measured memory_bytes: 1024
import sys

for line in sys.stdin :

  list = line.split(" ")
  
  for n in range(len(list)) : 
    list[n] = int(list[n])
   
  
list.sort()

if (list[0] == 5 and list[1] == 5 and list[2] == 7) :
  print('YES')
  
else :
  print('NO')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }

  vector<ll> cnts(1e6+5);
  rep(i,n) {
    ++cnts[a[i]];
  }

  auto check = [&](ll v) {
    if (cnts[v] > 0) { // found
      return true;
    }
    return false;
  };

  ll ans = 0;
  rep(i,n) {
    --cnts[a[i]];

    bool found = false;
    for (ll j = 1; j*j <= a[i]; ++j) {
      if (a[i]%j == 0) {
        if (check(j)) {
          found = true;
          break;
        }
        if (check(a[i]/j)) {
          found = true;
          break;
        }
      }
    }

    if (!found) {
      ++ans;
    }

    ++cnts[a[i]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 12640
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>
#include <queue>

#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < static_cast<ll>(n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define endl '\n'
#define f first
#define s second

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
string s;
vector<int> g[MAXN];

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    n = sz(s);
    s = "#" + s;

    if (s[n] == '1' || s[1] == '0') {
        cout << "-1\n";
        return ;
    }

    vector<int> comps;

    for (int i = 1; 2 * i <= n; ++i) {
        if (s[i] != s[n - i]) {
            cout << "-1\n";
            return ;
        }

        if (s[i] == '1') {
            comps.push_back(i);
        }
    }

    int root = 0;
    int cur = 1;

    for (auto c : comps) {
        while (cur < c) {
            dbg(c, root, cur);
            g[root].push_back(cur++);
        }

        g[cur++].push_back(root);
        root = cur - 1;
    }

    while (cur < n) {
        g[root].push_back(cur++);
    }

    for (int i = 0; i < n; ++i)
        for (auto to : g[i])
            cout << to + 1 << ' ' << i + 1 << endl;
}

int32_t main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    //freopen("/Users/leemonage/CLionProjects/proj/file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 26988
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e6+10;
const int INF=1e9+10;
int in[maxx];
int dp[maxx];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	fill(dp,dp+n,INF);
	for(int i=0;i<n;i++){
		scanf("%d",&in[i]);	
	}
	dp[0]=0;
	dp[1]=abs(in[0]-in[1]);
	for(int j=2;j<n;j++){
		for(int i=1;i<=k;i++)
		if(j-i>=0)
		dp[j]=min(dp[j],abs(in[j]-in[j-i])+dp[j-i]);
		/*for(int j=0;j<n;j++)
		printf("%d ",dp[j]);
		printf("\n")*/;
	}
	printf("%d",dp[n-1]);
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  string s, t;
  cin >> N >> s >> t;

  int ans = 2 * N;
  for (int i = N; i >= 1; i--) {
    if (s.substr(N - i, i) == t.substr(0, i)) {
      ans -= i;
      break;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int A=0;
  for(int i=0;i<N;i++){
    if (i%2==0){A+=vec.at(i);}
    if (i%2==1){A-=vec.at(i);}
  }
  cout << A << endl;
}


Measured memory_bytes: 3592
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, L = map(int, input().split())

A = [L+i-1 for i in range(1,N+1)]

if 0 in A:
    print(sum(A))
else:
    AA = [abs(a) for a in A]
    b = min(AA)
    if b in A:
        print(sum(A) - b)
    else:
        print(sum(A) + b)



Measured memory_bytes: 77312
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
int graph[101][101];
int main(){
    int n,u,k,v;
    scanf("%d",&n);
    fill(graph[0],graph[100],0);
    REP(i,n){
        scanf("%d%d",&u,&k);
        REP(j,k){
            scanf("%d",&v);
            graph[u][v]=1;
        }
    }
    REP(i,n){
        REP(j,n){
            if(j) printf(" ");
            printf("%d",graph[i+1][j+1]);
        }
        puts("");
    }
    return 0;
}




Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k;
llong a[200005];

int main() {
    cin >> k >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    a[0] = a[n] - k;
    a[n + 1] = a[1] + k;

    llong ans = 1ll << 60ll;
    for (int i = 1; i <= n; i++) {
        ans = min(ans,
                  min(k - llabs(a[i]  - a[i - 1]), k - llabs(a[i] - a[i + 1])));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
from collections import deque
n,q=map(int,input().split())
E=[[]for _ in range(n+1)]
P=[0]*(n+1)
V=[False]*(n+1)
for i in range(n-1):
   a,b=map(int,input().split())
   E[a].append(b)
   E[b].append(a)
for i in range(q):
   p,x=map(int,input().split())
   P[p]+=x
que=deque([1])
while que:
   s=que.popleft()
   V[s]=True
   for ni in E[s]:
      if V[ni]==False:
         P[ni]+=P[s]
         que.append(ni)
print(*P[1:])


Measured memory_bytes: 105804
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println((n-1)/2);
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll a[e5];
ll b[e5];
ll idx[e5];
ll x = 0;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> a[i] >> b[i];
  iota(idx,idx+n,0ll);
  sort(idx,idx+n,[](ll x,ll y){
    return b[x] < b[y];
  });
  for(ll i = 0;i < n;i++){
    x += a[idx[i]];
    if(x > b[idx[i]]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}


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



int main(void) {
	int a, b, count = 0;
	while (cin>> a>> b, a || b) {
		if (count)
			cout << endl;
		bool NAflag = 0;
		for (int i = a; i <= b; i += 4-i%4) {
			bool flag;
			if (i % 4 == 0) {
				if (i % 100 == 0) {
					if (i% 400 == 0) {
						flag = 1;
					} else {
						flag = 0;
					}
				} else {
					flag = 1;
				}
			} else {
				flag = 0;
			}
			if (flag) {
				NAflag = 1;
				cout<< i<< endl;
			}
		}
		if (!NAflag)
			cout<< "NA"<< endl;
		++count;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    if(c-b==b-a){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

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

int W, H;
vector<string> m;
bool m1[100][100] = {0};
string m2[100][100];
string beautify(string s) {
	if (s.size() == 0) return "";
	int l = (int)s.size()-1;
	REP(i,s.size()) {
		if (s[i] != '0') {
			l = i;
			break;
		}
	}
	return s.substr(l, s.size()-l);
}
bool gt(string s1, string s2) {
	bool r = s1.size() > s2.size();
	s1 = beautify(s1);
	s2 = beautify(s2);
	if (s1.size() == s2.size()) {
		if (s1 == s2) {
			return r;
		}
		return s1 > s2;
	}
	return s1.size() > s2.size();
}
string dp(int x, int y) {
	string res = "";
	if (x < 0 || x >= W || y < 0 || y >= H) return "";
	if ( !isdigit(m[y][x]) ) return "";
	if (m1[y][x]) return m2[y][x];
	REP(i, 2) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		string a = ""; a += m[y][x];
		a += dp(nx, ny);
		if ( gt(a, res) ) res = a;
	}
	return m1[y][x] = true, m2[y][x] = res;
}


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while (cin >> W >> H, W || H) {
		m.resize(H); cin >> m;
		fill(m1[0], m1[100], false);
		string ans = "0";
		REP(y, H) REP(x, W) {
			if ( gt( dp(x, y), ans ) ) ans = beautify( dp(x, y) );
		}
		cout << ans << endl;
	}
}

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

int main(){
 int a,b;
 char op;
 while(true){
 cin >> a >> op >> b;
 if(op == '?') break;
 else if(op == '+') cout << a+b << endl;
 else if(op == '-') cout << a-b << endl;
 else if(op == '*') cout << a*b << endl;
 else if(op == '/') cout << a/b << endl;
 }
}


Measured memory_bytes: 3112
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main
{
	public static void main(String[] args) throws Exception
	{
		Reader reader = new Reader();
      	int n = reader.nextInt();
      	int k = reader.nextInt();
		OutputStream out = new BufferedOutputStream(System.out);
		out.write((""+ fromDeci(k, n).length()).getBytes());
		out.flush();
	}
    static char reVal(int num) 
    { 
        if (num >= 0 && num <= 9) 
            return (char)(num + 48); 
        else
            return (char)(num - 10 + 65); 
    } 

    // Function to convert a given decimal number 
    // to a base 'base' and 
    static String fromDeci(int base1, int inputNum) 
    { 
        String s = ""; 

        // Convert input number is given 
        // base by repeatedly dividing it 
        // by base and taking remainder 
        while (inputNum > 0) 
        { 
            s += reVal(inputNum % base1); 
            inputNum /= base1; 
        } 
        StringBuilder ix = new StringBuilder(); 

            // append a string into StringBuilder input1 
            ix.append(s); 

        // Reverse the result 
        return new String(ix.reverse()); 
    } 

	static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            return ret;
        }
        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }
    }
}


Measured memory_bytes: 23252
import java.util.*;
import java.math.*;
public class Main {
	static int x;
	static int ans;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long h = in.nextLong();
		long cur = 1;
		long ans = 0;
		while(h > 0) {
			ans += cur;
			h = (long) Math.floor(h / 2);
			cur *= 2;
		}
		System.out.println(ans);
	}
} 

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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll mod = 1000000007

using namespace std;

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

    int ans = n/2;

    for(int i = 1; i <=n/2; i++){
        if(i*2 == n)ans--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

vector<ll> len;
vector<ll> np;

ll solve(ll n, ll x){
    if(n == 0){
        return (ll)(x > 0);
    }else if(x < len.at(n - 1) + 2){
        return solve(n - 1, x - 1);
    }else{
        return np.at(n - 1) + 1 +
            solve(n - 1, x - len.at(n - 1) - 2);
    }
}

int main(){
    ll n, x;
    cin >> n >> x;

    len.resize(n + 1, 0);
    np.resize(n + 1, 0);
    len.at(0) = 1;
    np.at(0) = 1;
    for(int i = 1; i <= n; ++i){
        len.at(i) = 2 * len.at(i - 1) + 3;
        np.at(i) = 2 * np.at(i - 1) + 1;
    }

    cout << solve(n, x) << endl;
    return 0;
}


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

public class Main {

    List<Integer>[] list;
    int[] dp;
    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        list = new List[n];
        for (int i = 0; i < n; i++) {
            list[i] = new ArrayList<>();
        }

        for (int i =0 ; i< m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            list[x].add(y);
        }
        dp = new int[n];
        Arrays.fill(dp, -1);
        // dp[i] ... ノードiからスタートする場合の最大経路長
        int ans = -1;
        for (int i = 0; i < n; i++) {
            ans = Math.max(ans, rec(i));
        }
        System.out.println(ans);
    }

    int rec(int i) {
        if (dp[i] != -1) {
            return dp[i];
        }
        int res = 0;
        for (int j : list[i]) {
            res = Math.max(res,rec(j) + 1);
        }
        
        dp[i] = res;
        return res;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 102812
def main():
    s = str(input())
    N = int(input())
    st = []
    moji = s[0]
    a = len(s)
    count = 1
    for i in range(a-1):
        if moji == s[i+1]:
            count += 1
        else:
            st.append(count)
            moji = s[i+1]
            count = 1
    st.append(count)
    ans = 0
    if len(st) == 1:
        ans = count*N//2
    else:
        for i in st:
            ans += i//2
        ans *= N
        if s[0] == s[-1]:
            ans += ((st[0]+st[-1])//2-st[0]//2-st[-1]//2)*(N-1)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
N = int(input())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

dp = [0] * (N+1)
for a, b in ((a, b) for a, b in zip(A, B) if a < b):
    for w in range(a, N+1):
        dp[w] = max(dp[w], dp[w-a] + b-a)

M = max(dp) + N
dp = [0] * (M+1)
for a, b in ((a, b) for a, b in zip(A, B) if a > b):
    for w in range(b, M+1):
        dp[w] = max(dp[w], dp[w-b] + a-b)

print(max(dp) + M)


Measured memory_bytes: 227820
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int x,y;
  	cin>>x>>y;
  	if((y>=2*x) && (y<=4*x) && (y%2==0))
      cout<<"Yes"<<endl;
  	else
    	cout<<"No"<<endl;
  return 0;
}

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

int main()
{
    ll k,n,m,ans;

    cin >> k >> n;
    vector<int> a(n + 1);
    rep(i, n) {
        cin >> a[i];
    }

    m = 0;
    rep(i, n-1) {
        if (m < (a[i + 1] - a[i]))
            m = a[i + 1] - a[i];
    }
    if (m < (k - a[n-1] + a[0]))
        m = (k - a[n-1] + a[0]);

    ans = k - m;
    std::cout << ans << endl;
}


Measured memory_bytes: 4052
a,b  =map(int,input().split())
c = b*10
lis = []
d = range(c,c+10)
l = list(d)
for j in l:
    if int(j*0.08)==a:
        lis.append(j)

if len(lis) ==0:
    print("-1")
else:
    print(lis[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int main() {
  LL N,flag=0;
  string S;
  cin>>N;
  for(int i=0; i<N; i++){
    cin>>S;
    if(S=="Y"){
      flag=1;
    }
  }
  if(flag==1){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
using namespace std;
typedef vector <int> vi;
typedef vector <vector<int>> vii;
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
typedef long double ld;

const long double PI=3.141592653589793238462643383279502884;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main(){
    fast;
    ll n,i,j;
    cin>>n;
    int a[100100];
    for (i=0;i<n;i++){
        cin>>a[i];
    }
    int cur=0;
    i=0;
    while (a[cur]!=2&&i<=n){
        cur=a[cur]-1;
        i++;
    }
    if (i==n+1){
        cout<<-1;
    } else {
        cout<<i+1;
    }
    return 0;
}





Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1e5+5;
int sg[N];
int a[105];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            if(i>=a[j]){
                if(sg[i-a[j]]==0){
                        sg[i]=1;
                        break;
                }
            }
        }
    }
    if(sg[k]) puts("First");
    else puts("Second");
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int n,i,j;
	int t1,t2,b1,b2,box[5000],v[5000];
	scanf("%d",&n);
	for(i=0;i<n*(n-1)/2;i++){
		v[i]=0;	box[i]=1;
	}
	for(i=0;i<n*(n-1)/2;i++){
		scanf("%d %d %d %d",&t1,&t2,&b1,&b2);
		if(b1>b2)	v[t1]+=3;
		if(b1<b2)	v[t2]+=3;
		if(b1==b2){
			v[t1]++;
			v[t2]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(v[i]>v[j])	box[j]++;
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",box[i]);
	}
	return 0;
}



Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001
#define INF         INT_MAX

int32_t main(){

	
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	while(1){

		c=c-b;
		if(c<=0){
			cout<<"Yes"<<endl;
			break;
		}
		a=a-d;
		if(a<=0){
			cout<<"No"<<endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3624
//============================================================================
// Name        : DPTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N;
int A[2001]={};
long long dp[2001][2001]={};

long long calc(int n1,int n2){
	long long ans=0;
	n1=(n1+N)%N;
	int e =(n1+n2-1)%N;
	if(dp[n1][n2]>0)return dp[n1][n2];
	if(n2<=1)return 0;
	if(n2==2)return min(A[n1],A[e]);
	if(A[n1]>A[e]){
		ans = max(A[(n1+1)%N]+calc(n1+2,n2-2),A[e]+calc(n1+1,n2-2));
	}else{
		ans = max(A[n1]+calc(n1+1,n2-2),A[(e-1+N)%N]+calc(n1,n2-2));
	}
	dp[n1][n2]=ans;
	return ans;
}
int main() {
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	long long R=0;
	for(int i=0;i<N;++i)R = max( R, calc(i+1,N-1)+A[i] );

	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 34428
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int n , w ;
int wiegth[101],values[101];
int dp[100001];

int32_t main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

        cin >> n >> w ; 
        for(int i=0;i<n;i++)
                cin >> wiegth[i] >> values[i];
        int sum_value = accumulate(values,values+n,0ll);
        fill(dp,dp+sum_value+1,10000000000000000);
        dp[0]=0;
        for(int i=0;i<n;i++){
                for(int j=sum_value-values[i];j>=0;j--){
                        dp[j+values[i]] = min(dp[j+values[i]],dp[j]+wiegth[i]);
                }
        }

        int ans =0 ;
        for(int i=0;i<=sum_value;i++){
                if(dp[i]<=w){
                        ans = i;
                }
        }

        cout << ans << endl;

        return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 2e3 + 5;

ll dp[N][N];

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

  int n;
  cin >> n;
  vector < pair < int, int > > a (n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i].first, a[i].second = i;

  sort (a.begin() + 1, a.end(), greater < pair < int, int > > ());

  for (int l = n; l >= 1; l--) {
    for (int r = l; r <= n; r++) {
      int idx = l + n - r;
      int i = a[idx].second;
      if (idx < 1 || idx > n) continue;
      if (l == r) {
        dp[l][r] = (ll)a[n].first * abs (r - i);
        continue;
      }
      dp[l][r] = max (dp[l + 1][r] + (ll)a[idx].first * abs(i - l), dp[l][r - 1] + (ll)a[idx].first * abs(r - i));
    }
  }

  cout << dp[1][n] << '\n';
}


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

int main(void){
    long N,A,B,n;
    scanf("%ld%ld%ld",&N,&A,&B);
    n =(N/(A+B))*A;
    if(N%(A+B) < A){
        n += N%(A+B);
    }
    else{
        n += A;
    }
    printf("%ld\n",n);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  ll an=0;
  vec c(a);
  For(i,0,a){
    ci(c[i]);
    if(c[i]>=b)
      an++;
  }
  co(an);
}

Measured memory_bytes: 1024
/*author - Ashutosh Chitranshi*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update>
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
   	ll y = x;
    int c = 1;
  	while(true)
    {
	    if(__gcd(y,360ll) == 360ll)
	    {
	       cout << c << nl;
	       break;
	    }
	    y += x;
	    c++;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

int n;
vector<ll> a;

int main() {
        cin >> n;
        a = vector<ll>(n);
        for (int i=0; i<n; ++i)
                cin >> a[i];

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

        ll one=0;
        ll two=0;
        for (int i=a.size()-1; i>=0; i--) {
                if (a[i] == a[i-1]) {
                        if (one == 0) {
                                one = a[i];
                        } else {
                                two = a[i];
                                break;
                        }
                        --i;
                }
        }

        cout << one*two << "\n";
}

Measured memory_bytes: 1024
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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 SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    REP(i, n){
        cin >> a[i];
    }
    lint sum = 0;
    lint sum_ = 0;
    REP(i, n){
        sum += a[i];
        if(i % 2 == 1){
            continue;
        }
        else if(i % 2 == 0 && i != n-1){
            sum_ += a[i];
        }
    }
    vector<lint> ans(n, 0);
    //debugpair(sum, sum_);
    ans[n-1] = (sum/2) - sum_;
    for (int i=n-2; i>=0; i--){
        ans[i] = a[i] - ans[i+1];
    }
    REP(i, n){
        if(i == 0){
            cout << ans[i] * 2;
        }
        else {
            cout << " " << ans[i] * 2;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n,m,a[N][N],b[N][N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int guass(int n)
{
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int p=i;
        while(p<=n&&!a[i][p]) p++;
        if(p==n+1) {ans++;continue;}
        swap(a[i],a[p]);
        for(int j=i+1;j<=n;j++)
            if(a[j][i])
            for(int k=i;k<=n;k++)
            a[j][k]^=a[i][k];
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&a[i][j]);
    int r=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        if(a[i][j])
        {
            if(b[j][j]) for(int k=j;k<=m;k++) a[i][k]^=b[j][k];
            else
            {
                for(int k=j;k<=m;k++) b[j][k]=a[i][k];
                r++;break;
            }
        }
    printf("%lld\n",qpow(2,n-1)*(qpow(2,m)+mod-qpow(2,m-r))%mod);
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, M, ans(0); std::cin >> N >> M;
    std::vector<std::pair<int, int>> AB(N);
    for(int i(0); i < N; ++i){
        std::cin >> AB[i].first >> AB[i].second;
    }
    std::sort(std::begin(AB), std::end(AB));
    std::priority_queue<int> que;
    {
        int j(0);
        for(int i(1); i <= M; ++i){
            while(j < N && AB[j].first <= i){
                que.push(AB[j].second);
                ++j;
            }
            if(!que.empty()){
            ans += que.top();
            que.pop();
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4684
population, kind = map(int,input().split())
lists = [0] * population
i = 0

while i <= kind -1:
  i += 1
  zaiko = int(input())
  j = 0
  posess = list(map(int,input().split()))
  while j <=  zaiko -1:
    lists[posess[j] - 1] = 1
    j += 1

k = 0
count = 0
while k <= population-1:
  if lists[k] == 0:
    count += 1
  k += 1

print(count)

Measured memory_bytes: 9204
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  string s; cin >> s;
  int x, y; cin >> x >> y;

  int cnt = 0;
  bool x_updated = false;
  vector<int> X, Y;
  rep(i, 0, SIZE(s)) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      if (x_updated) {
        Y.push_back(cnt);
      } else {
        X.push_back(cnt);
      }
      x_updated = !x_updated;
      cnt = 0;
    }
  }
  if (x_updated) {
    Y.push_back(cnt);
  } else {
    X.push_back(cnt);
  }


  vector< vector<bool> > x_list(SIZE(X)+1, vector<bool>(2*SIZE(s), false)), y_list(SIZE(Y)+1, vector<bool>(2*SIZE(s), false));
  x_list[1][X[0] +SIZE(s)] = true;
  y_list[0][0 +SIZE(s)] = true;
  rep(i, 1, SIZE(X)) {
    int x_step = X[i];
    rep(j, 0, 2*SIZE(s)) {
      if (x_list[i][j]) {
        if (j - x_step >= 0) {
          x_list[i+1][j - x_step] = true;
        }
        if (j + x_step < 2*SIZE(s)) {
          x_list[i+1][j + x_step] = true;
        }
        x_list[i][j] = false;
      }
    }
  }
  rep(i, 0, SIZE(Y)) {
    int y_step = Y[i];
    rep(j, 0, 2*SIZE(s)) {
      if (y_list[i][j]) {
        if (j - y_step >= 0) {
          y_list[i+1][j - y_step] = true;
        }
        if (j + y_step < 2*SIZE(s)) {
          y_list[i+1][j + y_step] = true;
        }
        y_list[i][j] = false;
      }
    }
  }

  if (x_list[SIZE(X)][x +SIZE(s)] && y_list[SIZE(Y)][y +SIZE(s)]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


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


int main(){
ll A;
  long double B;
  cin >> A >> B;
  
  
   cout << (long int)(A*B) ;
}

Measured memory_bytes: 3732
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]

dic=defaultdict(list)
for i in range(n-1):
    a,b=ab[i]
    dic[a].append(b)
    dic[b].append(a)
# print(dic)

itta=[0]*(n+1)
itta[1]=1
d=deque([[1,0,0]])

ans=k
while d:
    tmp=d.popleft()
    now,one,two=tmp
    j=0
    for i in range(len(dic[now])):
        if itta[dic[now][i]]==0:
            itta[dic[now][i]]=1
            ans*=k-1-two-j
            j+=1
            d.append([dic[now][i],one,one+1])
            ans%=mod
    # print(tmp,ans)

print(ans)

Measured memory_bytes: 114904
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
 
	crap;

	int n, k;
	cin >> n >> k;

	vector<int> arr(n), dp(n, INT_MAX);
	for (int i = 0; i < n; ++i){
		cin >> arr[i];
	}

	dp[0] = 0;
	for (int i = 1; i < n; ++i){
		for (int j = 1; j <= k; ++j){
			if(i - j >= 0){
				dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
			}
		}
	}

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


	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    int a,b,s=0,k=2;
    cin>>a>>b;
    while(k--)
    {
        if(a>=b)
            {s+=a;a--;}
        else {s+=b;b--;}

    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
"""
#


def solve(line1, line2):
    seq = []
    if len(line1) == 0:
        return 0
    elif len(line1) == 1:
        return 3
    else:
        prev_mark = line1[0]
        for m in line1[1:]:
            if prev_mark is None:
                prev_mark = m
                continue
            if m == prev_mark:
                seq.append('h')
                prev_mark = None
            else:
                seq.append('v')
                prev_mark = m
        if prev_mark:
            seq.append('v')

    if len(seq) == 1:
        return 6
    if seq[0] == 'h':
        ans = 6
        prev_p = 'h'
    else:
        ans = 3
        prev_p = 'v'

    for d in seq[1:]:
        if prev_p == 'h' and d == 'h':
            ans *= 3
            prev_p = 'h'
        elif prev_p == 'h' and d == 'v':
            prev_p = 'v'
        elif prev_p == 'v' and d == 'h':
            ans *= 2
            prev_p = 'h'
        else:
            ans *= 2
            prev_p = 'v'
    return ans % 1000000007




def main():
    n = int(input())
    line1 = input()
    line2 = input()
    result = solve(line1, line2)
    print(result)




if __name__ == '__main__':
    main()
    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int K; std::cin >> K;
	std::string S; std::cin >> S;
	if (K < S.size()) {
		std::string ans;
		for (int i{ 0 }; i < K; ++i) {
			ans.push_back(S[i]);
		}
		std::cout << ans << "..." << std::endl;
	}
	else {
		std::cout << S << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#define REP(i,n) for (int i=0;i<(n);++i)
const int INF = 1e9;

char N[3];

int main(){
    scanf("%s",N);

    for(int i = 0; i < sizeof(N) / sizeof(N[0]);++i){
        if(N[i]=='1') N[i] = '9';
        else if(N[i]=='9') N[i] = '1';
    }
    printf("%s\n",N);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <stack>
#include<cassert>
#include <cfloat>
#include <list>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define testMyStupedCode TCF--
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
void ReadFromFile( string name , string extention ){
    string fullPath = name + "." + extention ;
    freopen( fullPath.c_str() , "r" , stdin ) ;
}
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline char C(){
    char c ;
    scanf( "%c" , &c ) ;
    return c ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 3e3 + 5;
int dp[N][N], n, m;
char a[N], b[N];

int solve(int i, int j){
     if(i == n || j == m)
          return 0;
     int &ret = dp[i][j];
     if(~ret)
          return ret;
     ret = 0;
     if(a[i] == b[j])
          ret = max(ret, solve(i + 1, j + 1) + 1);
     else{
          ret = max(ret, solve(i + 1, j));
          ret = max(ret, solve(i, j + 1));
     }
     return ret;
}
void print(int i, int j){
     if(i == n || j == m)
          return;
     int ret = solve(i, j);
     if(ret == solve(i + 1, j))
          print(i + 1, j);
     else if(ret == solve(i, j + 1))
          print(i, j + 1);
     else{
          printf("%c", a[i]);
          print(i + 1, j + 1);
     }
}

int main(){
     memset(dp, -1, sizeof(dp));
     scanf("%s %s", a, b);
     n = strlen(a);
     m = strlen(b);
     solve(0, 0);
     print(0, 0);
     return 0;
}



Measured memory_bytes: 35840