akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    char c = ns()[0];

    if ('a' <= c && c <= 'z') {
      System.out.println("a");
    } else {
      System.out.println("A");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    string ta="",tb="";
    for(ll i=0;i<b;i++)
    ta+= to_string(a);
    for(ll i=0;i<a;i++)
    tb+= to_string(b);
    cout<<min(ta,tb)<<endl;
    
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    int N, j = 0;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    int c = 0;
    string tmp = "";
    for (int i = 0; i < N; i++) {
        if (S.at(i) != tmp) c++;
        tmp = S.at(i);
    }
    cout << c << endl;
}

Measured memory_bytes: 9600
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#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;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
//#define int ll 
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  int a ;cin >> a ;
  cout << a + a*a + a*a*a << endl ;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
int nxt[100005][26],now[26];
int main(){
    ios::sync_with_stdio(false);
    memset(now,-1, sizeof(now));
    cin>>s>>t;s="*"+s;
    for(int i=s.length()-1;i>=1;i--){
        for(int j=0;j<26;j++){
            nxt[i][j]=now[j];
        }
        now[s[i]-'a']=i;
    }
    for(int j=0;j<26;j++){
        nxt[0][j]=now[j];
    }
    for(int i=s.length()-1;i>=1;i--){
        for(int j=0;j<26;j++){
            nxt[i][j]=now[j];
        }
        now[s[i]-'a']=i;
    }
    ll ans=0,x=0;
    for(int i=0;i<t.length();i++){
        int p = nxt[x][t[i]-'a'];
        if(p==-1){cout<<-1<<endl;return 0;}
        if(p<=x)ans++;
        x=p;
    }
    cout<<1ll*ans*(s.length()-1)+x<<endl;
}


Measured memory_bytes: 10604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			int len = str.length();
			while (len > 0) {
				String five = str.substring(len - 5, len);
				if (five.equals("erase") || five.equals("dream")) {
					len -= 5;
					continue;
				} else {
					String six = str.substring(len - 6, len);
					if (six.equals("eraser")) {
						len -= 6;
						continue;
					} else {
						String seven = str.substring(len - 7, len);
						if (seven.equals("dreamer")) {
							len -= 7;
							continue;
						}
					}
				}
				break;
			}
			if (len == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 40692
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


divisors = make_divisors(N)
if len(divisors) % 2 == 0:
    print(divisors[int(len(divisors) // 2)] +
          divisors[int(len(divisors) // 2) - 1] - 2)
else:
    print(divisors[int(len(divisors) // 2)] * 2 - 2)


Measured memory_bytes: 3264
#include<stdio.h>
#include<algorithm>

int main()
{
    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)
            flag = 0;
        xx = x;
        yy = y;
        tt = t;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), B;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  deque<ll> q;
  for (auto e : A) {
    q.push_back(e);
  }
  ll ans = 0;
  ll right = q.front();
  ll left = right;
  q.pop_front();
  while (!q.empty()) {
    ll back = q.back();
    ll front = q.front();
    ll cand1 = abs(right - back);
    ll cand2 = abs(right - front);
    ll cand3 = abs(left - back);
    ll cand4 = abs(left - front);
    ll maximum_abs = max({cand1, cand2, cand3, cand4});
    ans += maximum_abs;
    if (maximum_abs == cand1) {
      right = back;
      q.pop_back();
    } else if (maximum_abs == cand2) {
      right = front;
      q.pop_front();
    } else if (maximum_abs == cand3) {
      left = back;
      q.pop_back();
    } else if (maximum_abs == cand4) {
      left = front;
      q.pop_front();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll n,x,y,m,a=0,b=0,tot=0,col[N];
ll f[N],nxt[N<<1];
struct E
{
	int u,v;
}e[N<<1];
void add(int u,int v)
{
	tot++;
	nxt[tot]=f[u];
	f[u]=tot;
	e[tot]=(E){u,v};
	return;
}
void dfs(int u,int fa,int c)
{
	col[u]=c;
	GO(u)
	{
		int v=e[j].v;
		if (v==fa) continue;
		if (col[v]==c)
		{
			printf("%lld\n",1LL*n*(n-1)/2-m);
			exit(0);
		}
		else if (!col[v]) dfs(v,u,c*-1);
	}
	return;
}
int main()
{
	mem(f,-1);
	scanf("%lld%lld",&n,&m);
	FOR(i,1,m) scanf("%lld%lld",&x,&y),add(x,y),add(y,x);
	dfs(1,0,1);
	FOR(i,1,n)
	{
		if (col[i]==1) a++;
		if (col[i]==-1) b++;
	}
	printf("%lld\n",1LL*a*b-m);
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

vvi adj;
vi color;

void dfs(int node, int c) {
	color[node] = c;
	for(int i : adj[node]) {
		if(!color[i]) dfs(i, c);
	}
}

void solve() {
	int n, m;
	cin >> n >> m;
	
	adj.resize(n);
	for(int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		
		x--; y--;
		adj[x].pub(y);
		adj[y].pub(x);
	}	
	
	int c = 0;
	color.resize(n, 0);
	for(int i = 0; i < n; i++) {
		if(!color[i]) dfs(i, ++c);
	}
	
	cout << c << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 11976
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);

using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    return out;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}
int n,k;
vector<ll> a;
vector<vector<ll> > dp;
vector<vector<bool> > visited;
ll solve(int first, int last)
{
    if(first>last)
        return 0;

    if(visited[first][last])
        return dp[first][last];
    
    visited[first][last]=true;

    if(first==last)
        return dp[first][last]=a[first];
    
    dp[first][last]=max(a[first]-solve(first+1,last),a[last]-solve(first,last-1));
    
    return dp[first][last];
}

int main()    
{
    #ifdef SANS
        freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
    #endif
    fast
    int t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        dp.resize(n,vector<ll>(n,-1));
        a.resize(n);
        cin>>a;
        visited.resize(n,vector<bool>(n,0));
        cout<<solve(0,n-1);
    }
    #ifdef SANS
        cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
    #endif
}

Measured memory_bytes: 74996
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  vector<ll> A(N);
  boost::for_each(A, [](auto& a){
    cin >> a;
  });
  boost::sort(A);
  auto it_m = A.end();
  --it_m;
  auto half0 = *it_m / 2;
  auto half1 = *it_m % 2 ? half0 + 1 : half0;

  auto res0 = boost::upper_bound(A, half0);
  auto res1 = boost::upper_bound(A, half1); --res1;
  if(*res0 == *it_m){
    --res0;
  }
  if(*res1 == *it_m){
    --res1;
  }

  ll res{};
  if(std::abs(half0 - *res0) < std::abs(half1 - *res1)){
    res = *res0;
  } else {
    res = *res1;
  }

  cout
    << *it_m
    << SPACE
    << res
    << CRLF;

  return;
}

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

  solve();

  return 0;
}


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






int main(void){
int n;
double x;
double sum=0.0;
char s[20];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lf",&x);
scanf("%s",s);
if(s[0]=='J'){sum=sum+(double)x;}
else if(s[0]=='B'){sum=sum+(double)x*380000.0;}
}
printf("%lf",sum);
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(n):
  if a[i]%4==2:
    cnt1+=1
  if a[i]%4==0:
    cnt2+=1
if cnt2>=n//2 or cnt1+cnt2==n-cnt2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
n = int(input())
l = list(map(int, input().split()))

max_index = l.index(max(l))
cnt = 0
for i in range(len(l)):
    if not  i == max_index:
        cnt += l[i]
if cnt > l[max_index]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
use std::vec::Vec;
use std::iter::FromIterator;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let s: Vec<char> = read::<String>().chars().collect();
  let mut ans = vec![];
  for c in s {
    if c == ',' {
       ans.push(' ');
       continue
    }
    ans.push(c);
  }

  let ans = String::from_iter(ans);
  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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 pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

//ll a[220000];
int main(){
    ll n,k,a,b,ans=0;
    cin>>k>>a>>b;
    bool p=false;
    rep(i,a,b+1){
        if(i%k==0)p=true;
    }
    if(p)cout<<"OK";
    else cout<<"NG";
    //cout<<ans;
}


Measured memory_bytes: 3636
// Using fgets(3) and strtol(3) to obtain integers. 
// It may be faster than scanf(3) version sometimes. 
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

int64_t solve(char *begin, char *end);

int main(int argc, char const* argv[])
{
  char *next;
  int64_t N, Q;
  char buf[32];
  fgets(buf, sizeof(buf), stdin);
  N = strtol(buf, &next, 10);
  Q = strtol(next + 1, NULL, 10);
  // fprintf(stderr, "N = %ld, Q = %ld\n", N, Q);
  
  char *S = malloc((size_t)N + 2);
  fgets(S, N + 2, stdin);
  S[N + 1] = '\0';
  S[N] = '\0';
  // getchar();

  int64_t R[N];
  memset(R, 0, 8 * N);
  for (int i = 0; i < N - 1; i++) {
    R[i + 1] = R[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);
  }

  int64_t l, r, res;

  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = R[r - 1] - R[l - 1];
    printf("%lu\n", res);
  }

  /*
  // Bad code! TLE
  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = solve(S + l - 1, S + r - 1);
    printf("%lu\n", res);

  }
  */
  free(S);
  return 0;
}

int64_t solve(char *begin, char *end) {
  int64_t res = 0;
  for (; begin < end; begin++) {
    if ((begin[0] == 'A') && (begin[1] == 'C')) {
      res++;
      begin++;
    }
  }
  return res;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m),b(m),c(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i) >> c.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	ll INF=-1000000000000000000;
	vector<ll> dist(n,INF);
	dist[0]=0;
	rep(k,n){
		rep(i,m){
			dist.at(b.at(i))=max(dist.at(b.at(i)),dist.at(a.at(i))+c.at(i));
		}
	}
	ll ans=dist.at(n-1);
	rep(i,m){
		dist.at(b.at(i))=max(dist.at(b.at(i)),dist.at(a.at(i))+c.at(i));
	}
	if(ans==dist.at(n-1)) cout << ans << endl;
	else cout << "inf" << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int H,N;
vector<pair<int,int>> magic;

int ans = 0;
 
void solve(){
	vector<int> dp(H+1,INT_MAX-10000);
	dp[0] = 0;
	//dp[j] = i個目までを使ってAの和がjのときの最小コスト
	for(int i=0;i<N;i++){
		for(int j=0;j<H;j++){
			int nj = min(j+magic[i].first,H);
			dp[nj] = min(dp[nj],dp[j]+magic[i].second);
		}
	}
	ans = dp[H];
}
 
int main(){
	cin>>H>>N;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		magic.push_back(make_pair(a,b));
	}

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
l=[]
for _ in range(q):
    l.append(list(map(int,input().split())))
count=[0]*n
z=0
for i in range(1,n):
    if s[i-1]=='A' and s[i]=='C':
        z=1
    count[i]=count[i-1]+z
    z=0
for  j in range(q):
    print(count[l[j][1]-1]-count[l[j][0]-1])

Measured memory_bytes: 32248
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var min = Math.pow(10,15) + 1;
	var A = nextInt();
	min = Math.min(min, A);
	var B = nextInt();
	min = Math.min(min, B);
	var C = nextInt();
	min = Math.min(min, C);
	var D = nextInt();
	min = Math.min(min, D);
	var E = nextInt();
	min = Math.min(min, E);
	if(min >= N){
		myout(5);
	}else{
		var output = Math.floor(N / min);
		if(N % min != 0){
			output++;
		}
		myout(output + 4);
	}
}


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

int main() {
  int n; cin >>n;
  if (n==1){
    cout <<"Hello World";
  }else if (n==2){
    int a,b; cin >>a >>b;
    cout <<a+b;
  }
  //cout <<s;
  cout <<endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
x = 0

for i in range(1, n):
    a,b = set(s[:i]), set(s[i:])
    if max(len(a),len(b))-max(len(a-b),len(b-a))>x:
        x = max(len(a),len(b))-max(len(a-b),len(b-a))

print(x)

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

int main()
{
	int w,m,f;
	while(cin >> m)
	{
		f=w=1;
		while(m)
		{
			if(m&1)
			{
				cout << (f?"":" ") << w; f=0;
			}
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

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

using namespace std;

// Solve function here


// End Solve function

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	int vote[n];
	for(int i = 0; i < n; i++) cin >> vote[i];
	int sum = 0;
	for(int i = 0; i < n; i++) sum += vote[i];
	int am = sum / (4*m);
	if(sum % (4*m)) am++;
	sort(vote, vote+n);	
	int res = 0;
	for(int i = n-1; i >= 0; i--){
		if(vote[i] >= am) res++;
	}
	if(res >= m) cout << "Yes\n";
	else cout << "No\n";
  	return 0;
	
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    auto N = readln.chomp.map!(ch => ch - '0').array;
    auto L = N.length.to!int;

    debug {
        writeln(N);
    }

    int K;
    scan(K);

    auto dp = new long[][][](L + 1, 2, K + 2);
    dp[0][0][0] = 1;
    
    foreach (i ; 0 .. L) {
        foreach (j ; 0 .. 2) {
            foreach (x ; 0 .. K + 2) {
                foreach (d ; 0 .. (j ? 9 : N[i]) + 1) {
                    if (x == K + 1) {
                        dp[i + 1][j | (d < N[i])][x] += dp[i][j][x];
                    }
                    else {
                        dp[i + 1][j | (d < N[i])][x + (d != 0)] += dp[i][j][x];
                    }
                }
            }
        }
    }

    auto ans = dp[L][0][K] + dp[L][1][K];
    writeln(ans);
}










void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#マージソート
from collections import deque
n = int(input())
S = list(map(int, input().split()))
INFTY = 1e9 + 1

def merge(S, left, mid, right):
    global cnt
    L = deque(S[left:mid])
    R = deque(S[mid:right])
    L.append(INFTY)
    R.append(INFTY)
    for k in range(left, right):
        S[k] = (L if L[0] < R[0] else R).popleft()
    cnt += right - left
    
def merge_sort(S, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(S, left, mid)
        merge_sort(S, mid, right)
        merge(S, left, mid, right)
        
cnt = 0
merge_sort(S, 0, n)
print(*S)
print(cnt)


Measured memory_bytes: 67876
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			int s = sc.nextInt();
			boolean ok = false;
			for(int j = 1; j*j <= s+1; j++) {
				if((s - j) % (1 + 2 * j) == 0) {
					ok = true;
					break;
				}
			}
			if(!ok) count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 66876
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, q;
string s;
int memo[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> q >> s;

  fill(memo, memo + n + 1, 0);

  FOR(i, 1, n) {
    if(s[i] == 'C' && s[i - 1] == 'A') memo[i] = memo[i - 1] + 1;
    else memo[i] = memo[i - 1];
  }

  REP(i, q) {
    int a, b;
    cin >> a >> b;
    a--; b--;

    cout << (memo[b] - memo[a]) << endl;
  }
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }


int main() {
    string s; cin >>s ;
    if(s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


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

int main(){
  int s;
  cin >> s;
  set<int> S;
  S.insert(s);
  int ans = 1;
  while(true){
    if(s % 2 == 0) s = s/2;
    else s = 3*s + 1;
    ans++;
    set<int>::iterator ite = S.find(s);
    if(ite != S.end()){
      break;
    }
    S.insert(s);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (Nl, C) = listOfLong()
    val N = Nl.toInt()
    val x = LongArray(N)
    val v = LongArray(N)
    repeat(N) { n ->
        val (X, V) = listOfLong()
        x[n] = X; v[n] = V
    }
    val dl = LongArray(N + 1)
    val dr = LongArray(N + 1)
    repeat(N) { n -> dl[n + 1] = dl[n] + v[n] }
    repeat(N) { n -> dr[n + 1] = dr[n] + v[N - 1 - n] }
    val dp1 = LongArray(N + 1)
    val dp2 = LongArray(N + 1)
    repeat(N) { n ->
        dp1[n + 1] = Math.max(dp1[n], dl[n] + v[n] - x[n])
        dp2[n + 1] = Math.max(dp2[n], dr[n] + v[N - 1 - n] - (C - x[N - n - 1]))
    }
    var ans = 0L
    repeat(N + 1) { n ->
        ans = Math.max(ans, dp1[n] + dp2[N - n] - (if (n == 0) 0 else x[n - 1]))
        ans = Math.max(ans, dp1[n] + dp2[N - n] - (if (n == N) 0 else (C - x[n])))
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong(d: Int = 0) = listOfString().map { it.toLong() + d }


Measured memory_bytes: 60076
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        private const long M = 1000000007;       // 素数(int範囲)

        static int N;
        static int K;

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());

            double ans = 0;
            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                switch(s[1])
                {
                    case "JPY":
                        ans += (double)(int.Parse(s[0]));
                        break;

                    case "BTC":
                        ans += (double.Parse(s[0]) * 380000.0);
                        break;
                }
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e18L + 5;

void min_self(ll& a, ll b){
    a= min(a, b);
}

int main(){
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n), value(n);
    for(ll i = 0; i < n; i++){
        cin>>weight[i]>>value[i];
    }
    ll sum_value = 0;
    for(ll i = 0; i < n; i++){
        sum_value = sum_value + value[i];
    }
    vector<ll> dp(sum_value + 1, INF);
    dp[0]=0;
    for(ll item = 0; item < n; item++){
        for(ll value_already = sum_value - value[item]; value_already >= 0; value_already--){
            min_self(dp[value_already + value[item]], dp[value_already] + weight[item]);
        }
    }
        ll answer = 0;
        for(ll i = 0; i <= sum_value; i++){
            if(dp[i] <= w){
                answer = max(answer, i);
            }
        }
cout<<answer;

    return 0;
}



Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
void anser(bool a) { cout << (a ? "Yes" : "No" ) << endl; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])puts("Yes");
  else puts("No");
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    double pi = 3.141592;
    int r;
    cin >> r;
    cout << (2 * pi * r) << endl;
    return 0;
}

Measured memory_bytes: 3800
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    pr a[N];int left[N],right[N];
    void main()
	{
        int n=qread();fo(i,1,n) a[i].FR=qread(),a[i].SE=qread();sort(a+1,a+n+1);
        int mi=1;fo(i,1,n) if(a[i].SE<=a[mi].SE) mi=i;
        left[1]=a[1].SE;fo(i,2,n) left[i]=max(left[i-1],a[i].SE);
        right[n]=a[n].SE;fd(i,n-1,1) right[i]=min(right[i+1],a[i].SE);
        int ans=-1;
        fo(lst,1,n-1)
        {
            int now=max(
                max(0,a[mi].SE-a[lst].FR+1)+max(0,right[lst+1]-a[n].FR+1),
                max(0,left[lst]-a[lst].FR+1)+max(0,a[mi].SE-a[n].FR+1)
            );
            chmax(ans,now);
        }
        write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    if (n%2){
        ll l = 1,r = n;
        rep(i,m){
            printf("%lld %lld\n",l,r);
            l++;
            r--;
        }
    }
    else{
        ll k = n/2;
        ll l = 1,r = n;
        rep(i,min(k/2,m)){
            printf("%lld %lld\n",l,r);
            l++;
            r--;
        }
        r--;
        rep(i,m-k/2){
            printf("%lld %lld\n",l,r);
            l++;
            r--;
        }
    }
}


Measured memory_bytes: 3780
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	long long X;
	cin >> X;

	long long ans = 100;
	int count = 0;
	while (ans < X) {
		ans += ans / 100;
		++count;
	}
	
	cout << count << endl;

	return 0;
}




Measured memory_bytes: 3632
import numpy as np
from collections import deque

N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

# BFS
def dist_from_X(X:int):
    dist = np.full(N, -1)
    que = deque([X])
    dist[X] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for e in E[v]:
            if dist[e] > -1:
                continue
            dist[e] = d + 1
            que.append(e)
    return dist

Fennec = dist_from_X(0)
Sunuke = dist_from_X(N-1)

cnt = np.count_nonzero(Fennec <= Sunuke)

if cnt > N - cnt:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 31716
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	double in;
	while(cin>>in,in+1){
		string s="";
		rep(i,8){
			int h=in/pow(2,7-i);
			s+=(char)(h+'0');
			if(h)in-=pow(2,7-i);
		}
		s+=".";
		rep(i,4){
			int h=in/pow(2,-(i+1));
			s+=(char)(h+'0');
			if(h)in-=pow(2,-(i+1));
		}
		if(in)cout<<"NA"<<endl;
		else cout<<s<<endl;
	}
}

Measured memory_bytes: 1272
package main

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

func main() {
	a, b := getInt(), getInt()
	fmt.Println(max(a+b, a-b, a*b))
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
const int mod = (int)1e9 + 7;
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}

const int maax = 5050;
int f[maax][maax];

bool cmp(pi &a, pi &b)
{
	return (a.F+a.S < b.F +b.S);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vpi all(n);
	REP(i,0,n)
	{
		cin >> all[i].S >> all[i].F;
	}
	sort(all.B,all.E, cmp);
	int ans = 0;
	REP(i, 1 ,n+1)
	{
		for (int j = n; j >= 1; j--)
		{
			if ((f[i-1][j-1]^(j==1))&&(f[i-1][j-1] <= all[i-1].S))
			{
				f[i][j] = (f[i][j] == 0 ? f[i-1][j-1] + all[i-1].F : min(f[i][j], f[i-1][j-1] + all[i-1].F));
				ans = max(ans, bool(f[i][j]) *j);
			}
			if (f[i-1][j])
				f[i][j] = min(f[i][j],f[i-1][j]);
			if (!f[i][j])f[i][j] = f[i-1][j];
		}
	}		
	cout << ans;
}


Measured memory_bytes: 98944
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=205;

int n,A,k,Xor;

inline int Get(int x){
	if(x<k) return 0;
	if(x%k==0) return x/k;
	int der=x/k+1,lef=x%k;
	if(der>=lef) return Get(x-der);
	else return Get(x-lef/der*der);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&A,&k);
		Xor^=Get(A);
	}
	
	if(Xor) puts("Takahashi");
	else puts("Aoki");
	
	return 0;
}

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

using namespace std;
#define lint long long

int main() {
    
//    dpまとめ H
    int H, W;
    cin >> H >> W;
    
    const lint mod = 1000000007;
    
    vector<string> a(H + 1);
    
    for(int i = 0; i < H; ++i){
        cin >> a[i];
    }
    
    lint dp[H + 1][W + 1];
    
    dp[0][0] = 1;
    
    for(int i = 1; i < W; ++i){
        if(a[0][i] == '#'){
            dp[0][i] = 0;
        } else {
            dp[0][i] = dp[0][i - 1];
        }
    }
    for(int i = 1; i < H; ++i){
        if(a[i][0] == '#'){
            dp[i][0] = 0;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }
    
    for(int i = 1; i < H; ++i){
        for(int j = 1; j < W; ++j){
            if(a[i][j] == '#'){
                dp[i][j] = 0;
            } else {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
        }
    }
    
    cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 9088
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();
			
			int[][] A = new int[n][m];
			int[][] B = new int[m][l];
			long[][] C = new long[n][l]; 
			
			for(int i=0;i<n;i++) {
				for(int j=0;j<m;j++) {
					A[i][j] = sc.nextInt();
				}
			}
			for(int i=0;i<m;i++) {
				for(int j=0;j<l;j++) {
					B[i][j] = sc.nextInt();
				}
			}
			
			for(int i=0;i<n;i++) {
				for(int j=0;j<l;j++) {
					for(int k=0;k<m;k++) {
						C[i][j] += (long)A[i][k] * B[k][j]; 
					}
				}
			}
			
			for(int i=0;i<n;i++) {
				for(int j=0;j<l;j++) {
					System.out.print(C[i][j]);
					if(j!=l-1) {
						System.out.print(" ");
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 54352
l = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

N = input() # 0~26
S = input() # 英大文字

ans = ""
for s in S:
    ans += l[(l.index(s)+int(N))%26]

print(ans)

Measured memory_bytes: 41452
OFFSETS = [(-1,0),(0,-1),(0,1),(1,0)]

H, W = map(int, input().split())

Ses = []
for _ in range(H):
    Ses.append(input())

for y in range(H):
    for x in range(W):
        if Ses[y][x] == "#":
            found = False
            for dx, dy in OFFSETS:
                now_x = x+dx
                now_y = y+dy
                if now_x < 0 or now_x >= W:
                    continue
                if now_y < 0 or now_y >= H:
                    continue
                if Ses[now_y][now_x] == "#":
                    found = True
                    break
            if not found:
                print("No")
                exit()

print("Yes")


Measured memory_bytes: 3064