akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(e,y);
    if(e==0){
        if(y<=1911)printf("M%d\n",y-1868+1);
        else if(y<=1925)printf("T%d\n",y-1912+1);
        else if(y<=1988)printf("S%d\n",y-1926+1);
        else printf("H%d\n",y-1989+1);
    }else{
        if(e==1)printf("%d\n",y+1868-1);
        else if(e==2)printf("%d\n",y+1912-1);
        else if(e==3)printf("%d\n",y+1926-1);
        else printf("%d\n",y+1989-1);
    }
}


Measured memory_bytes: 3224
#include<stdio.h>
#include<math.h>

int main(){
    int i,x,y,z,f,n,count=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i<6){
            printf("0\n");
            continue;
        }
    for(x=1;x<=(int)sqrt(i) && x<=40;x++){
        if(6*x*x==i){
            count++;
        }
    }
    for(x=1;x<=(int)sqrt(i);x++){
        for(y=x+1;y<=(int)sqrt(i);y++){
            if(3*x*x+y*y+2*x*y==i){
                count += 3;
            }
        }
    }
    for(x=1;x<=(int)sqrt(i);x++){
        for(y=x+1;y<=(int)sqrt(i);y++){
            if(3*y*y+x*x+2*x*y==i){
                count += 3;
            }
        }
    }
    for(x=1;x<=(int)sqrt(i);x++){
        for(y=x+1;y<=(int)sqrt(i);y++){
            for(z=y+1;z<=(int)sqrt(i);z++){
                if(x*x+y*y+z*z+x*y+y*z+z*x==i) count += 6;
            }
        }
    }
    printf("%d\n",count);
    count=0;
    }
    return 0;
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int L,N;
int pos[35];
int nega[35];
vector<pair<int,int> > anss;
int main(void)
{
  cin >> L >> N;
  for(int i=0;i<N;i++)
    {
      int x,w;
      cin >> x >> w;
      if(x>0)
	{
	  pos[x]+=w;
	}
      else if(x<0)
	{
	  nega[x*(-1)]+=w;
	}
    }
  for(int i=1;i<=L;i++)
    {
      if(pos[i]!=nega[i])
	{
	  if(pos[i]>nega[i])
	    {
	      anss.push_back(make_pair(i*(-1),pos[i]-nega[i]));
	    }
	  else if(nega[i]>pos[i])
	    {
	      anss.push_back(make_pair(i,nega[i]-pos[i]));
	    }
	}
    }
  cout << int(anss.size()) << endl;;
  for(int i=0;i<anss.size();i++)
    {
      cout << anss[i].first << ' ' << anss[i].second << endl;
    }
  return 0;
}



Measured memory_bytes: 3108
package main

import (
	"bytes"
	"fmt"
	"strings"
)

func main() {
	var o, e string
	fmt.Scan(&o, &e)
	os := strings.Split(o, "")
	es := strings.Split(e, "")
	osLen := len(os)
	esLen := len(es)
	var out bytes.Buffer
	for i := 0; i < 50; i++ {
		if i < osLen {
			fmt.Fprint(&out, os[i])
		}
		if i < esLen {
			fmt.Fprint(&out, es[i])
		}
	}
	fmt.Print(out.String())
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int Bsearch(int e,int n){
  //cout << n << endl;
  int l=0,r=e;
  int i=(l+r)/2;
  while(r-l>=1){
    i=(l+r)/2;
    //cout << "i:" << i << endl;
    if(e == pow(i,n)){
      //cout << "aaa:" << i << endl;
      return i;
    }else if(e > pow(i,n)){
      l=i+1;
    }else{
      r=i;
    }
  }
  //cout << "i:" << i << endl;
  return i;
}

int a[2000][2000];

int main(){
  int x,y,z,e;
  while(cin>>e,e){
    memset(a,0,sizeof(a));
    y=Bsearch(e,2);
    z=Bsearch(e,3);

    int m=1000000;
    //cout << "z:" << z << " y:" << y << endl;
    for(int i=0;i<=y;i++){
      for(int j=0;j<=z;j++){
	x=e-i*i-j*j*j;
	if(x>=0)m = min(x+i+j,m);
      }
    }
    cout <<m << endl; 
  }
}

Measured memory_bytes: 16892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int a=sc.nextInt();
		pl((a-30)/2);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}



Measured memory_bytes: 24240
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		char [][] grid = new char[H+1][W+1];
		for(int i=1;i<=H;i++){
			String line = sc.nextLine();
			for(int j=0;j<line.length();j++){
				grid[i][j+1] = line.charAt(j);
			}
		}
		long [][] dp = new long[1001][1001];
		dp[H][W] = 1;
		int MOD = (int)1e9+7;

		for(int i=H;i>=1;i--){
			for(int j=W;j>=1;j--){
				if(i==H && j==W) dp[i][j]=1;
				else if(grid[i][j]=='#') dp[i][j] = 0;
				else {
					dp[i][j] = (((i==H) ? 0 : dp[i+1][j]) + ((j==W) ? 0 : dp[i][j+1]))%MOD;
				}
			}
		}

		return dp[1][1];

	}
}

Measured memory_bytes: 64440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

string s;
bool judge, first;
int main(){
    cin >> s;

    if(s.length()%2 == 1){
        first= true;
    }
    judge = s[0] == s[s.length()-1];

    if(!first){
        if(judge)   cout << "First\n";
        else    cout << "Second\n";
    }
    else{
        if(judge)   cout << "Second\n";
        else    cout << "First\n";
    }

}

Measured memory_bytes: 512
N, W = list(map(int, input().split()))
w=[0]*N
v=[0]*N
for i in range(N):
    w[i], v[i]=list(map(int, input().split()))
# print(w)
# print(v)

# dp[i][j]:i番目の品物までから重さj（以下）になるようにモノを詰めた時の価値の最大
# 配ってみるのはダルいからまずは普通に貰ってみる

dp=[[0 for i in range (W+1)] for j in range(N)]
for j in range(w[0],W+1):
    dp[0][j]=v[0]

for i in range(1,N):
    for j in range(W+1):
        if j>=w[i]:
            dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])
        else:
            dp[i][j]=dp[i-1][j]
    # print(dp)
print(dp[N-1][W])


Measured memory_bytes: 217984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    string fs="";
    rep(0,i,3){
        string s0=s.substr(i,1);
        if(fs==""){
            fs=s0;
        }else{
            if(fs!=s0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int X = x1 - x2;
  int Y = y1 - y2;
  int x3, y3, x4, y4;
  x3 = x2 + Y; y3 = y2 - X; x4 = x1 + Y; y4 = y1 - X;
  cout << x3<< " " << y3 << " " << x4 << " " << y4;
    return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
    [n, k] <- map read . words <$> getLine :: IO [Integer]
    as <- map read . words <$> getLine :: IO [Int]
    print $ solve k as

solve k as = ((f as) * k + (g as) * k * (k-1) `div` 2) `mod` (10^9+7)
    where f [] = 0
          f (a:as) = fromIntegral (length (filter (a >) as)) + f as
          g as = sum $ map (\a -> fromIntegral (length (filter (a >) as))) as

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

int main()
{
    int a,b,c ;

    cin >>a >>b >>c ;

    if(a==5  && b==5 && c==7) cout << "YES" << endl ;
    else if(a==5  && b==7 && c==5) cout << "YES" << endl ;
    else if(a==7  && b==5 && c==5) cout << "YES" << endl ;
    else cout << "NO" << endl ;

    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
//#include<stdlib.h>
using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	
	if (a > b) { cout << b; }
	else { cout << a; }
	cout <<" "<< ((a+b-n>0)?(a + b - n):(0));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){

  int n;
  I(n);
  int ar[n+2];
  for(int i = 1;i<=n;i++)I(ar[i]);
  int ans = 100000000;
  for(int i = 1;i<=100;i++){
      int res = 0;
      for(int j = 1; j<=n;j++){
          res += (i - ar[j]) *(i- ar[j]);
      }
      ans = min(ans, res);
  }

  cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <list>
#include <stack>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

void rec(V& id, int i, int j, const M& tree){
    for(auto to: tree[i]){
        if(id[to] != j){
            id[to] = j;
            rec(id, to, j, tree);
        }
    }
}

V connect(int n, int m, const V& xs, const V& ys){
    M tree(n);
    for(int i = 0; i < m; i++){
        tree[xs[i] - 1].push_back(ys[i] - 1);
        tree[ys[i] - 1].push_back(xs[i] - 1);
    }
    V id(n, -1);
    stack<int> st;
    for(int i = 0; i < n; i++){
        if(id[i] == -1){
            id[i] = i;
            rec(id, i, i, tree);
        }
    }
    return id;
}

V solve(int n, int k, int l, V& ps, V& qs, V& rs, V& ss){
    const V& as = connect(n, k, ps, qs);
    const V& bs = connect(n, l, rs, ss);
    map<P, int> counter;
    for(int i = 0; i < n; i++){
        counter[P(as[i], bs[i])]++;
    }
    V ts(n);
    for(int i = 0; i < n; i++){
        ts[i] = counter[P(as[i], bs[i])];
    }
    return ts;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k, l;
    cin >> n >> k >> l;
    V ps(k), qs(k);
    for(int i = 0; i < k; i++){
        cin >> ps[i] >> qs[i];
    }
    V rs(l), ss(l);
    for(int i = 0; i < l; i++){
        cin >> rs[i] >> ss[i];
    }

    const V& ts = solve(n, k, l, ps, qs, rs, ss);
    for(int i = 0; i < ts.size() - 1; i++){
        cout << ts[i] << " ";
    }
    cout << ts[ts.size() - 1] << endl;

    return 0;
}


Measured memory_bytes: 15656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    s.erase(4,1);
    s.erase(6,1);
    int num = stoi(s);
    if(num <= 20190430)
        cout << "Heisei" << "\n";
    else
        cout << "TBD" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    int H,W; cin>>H>>W;
    int A[H][W];
    rep(i,H){
        rep(j,W) cin>>A[i][j]; 
    }
    int ct=0;
    vector<int> ans[4];

    rep(i,H-1){
        rep(j,W){
            if(A[i][j]%2==1){
                ++ct;
                ans[0].emplace_back(i+1);
                ans[1].emplace_back(j+1);
                ans[2].emplace_back(i+2);
                ans[3].emplace_back(j+1);
                ++A[i+1][j];
            }
        }
    }

    rep(j,W-1){
        if(A[H-1][j]%2==1){
            ++ct;
            ans[0].emplace_back(H);
            ans[1].emplace_back(j+1);
            ans[2].emplace_back(H);
            ans[3].emplace_back(j+2);
            ++A[H-1][j+1];
        }
    }

    cout<< ct<<"\n";
    rep(i,ct){
        cout<< ans[0][i] <<" "<< ans[1][i] <<" "<< ans[2][i] <<" "<< ans[3][i] <<"\n";
    }


}   
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

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

    int cnt[3] = {};
    for(auto &c: s)
        cnt[c-'a']++;

    int mx = 0, mn = 1e9;
    for(int i=0; i<3; i++)
        mx = max(mx, cnt[i]);
    for(int i=0; i<3; i++)
        mn = min(mn, cnt[i]);

    cout << (mx - mn <= 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

string ans[3] = {"pairwise coprime", "setwise coprime", "not coprime"};

signed main(){

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

  vector<int> d(1e6 + 1, -1);
  d[1] = 1;
  for(int i = 2; i <= 1e6; i++){
    if(d[i] != -1) continue;
    for(int j = i; j <= 1e6; j+=i){
      if(d[j] == -1) d[j] = i;
    }
  }

  bool judge = true;
  set<int> visited;
  for(int i = 0; i < n; i++){
    int t = a[i];
    set<int> st;
    while(t != 1){
      st.insert(d[t]);
      t /= d[t];
    }
    for(int p : st){
      if(visited.find(p) != visited.end()) judge = false;
      visited.insert(p);
    }
  }

  if(judge){
    cout << ans[0] << endl;
    return 0;
  }

  int val = a[0];
  for(int i = 0; i < n; i++){
    val = __gcd(val, a[i]);
  }
  cout << (val == 1 ? ans[1] : ans[2]) << endl;

  return 0;
}


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

long long arr[1000005];

void traverse(long long n){
  int state = 0; 
  long long ans = 1; 

  for(int i = 0; i < n; i++){
    if(state == 0){ // Neutral;
      if(i == 0){
        state = 0;
      }
      else{
        if(arr[i] > arr[i - 1]){
          state = 1;
        }
        else if(arr[i] < arr[i - 1]){
          state = -1;
        }
      }
    }
    else if(state == 1){ // Ascending;
      if(arr[i] < arr[i - 1]){
        ans++; 
        state = 0; 
      }
    }
    else{ // Descending = State is -1;
      if(arr[i] > arr[i - 1]){
        ans++;
        state = 0; 
      }
    }
  }
  cout << ans << endl; 
}

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

  for(long long i = 0; i < n; i++){
    cin >> arr[i];
  }
  traverse(n);
}

Measured memory_bytes: 1024
import java.util.Scanner

val INF = Long.MAX_VALUE
fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val l = scn.nextInt()
	var map = Array(n){ a -> LongArray(n){ b-> if (a==b) 0 else INF }}
	repeat(m) {
		val a = scn.nextInt() - 1
		val b = scn.nextInt() - 1
		val c = scn.nextLong()
		map[a][b] = c
		map[b][a] = c
	}
	map = wfa(map)
	for (a in 0 until n) {
		for (b in 0 until n) {
			if (a!=b) {
				if (map[a][b]>l) map[a][b] = INF
				else map[a][b] = 1
			}
		}
	}
	map = wfa(map)
	val q = scn.nextInt()
	repeat(q){
		val s = scn.nextInt() - 1
		val t = scn.nextInt() - 1
		println(if (map[s][t]!=INF) map[s][t]-1 else -1)
	}
}

fun wfa(map: Array<LongArray>): Array<LongArray>{
	for (k in map.indices){
		for (b in map.indices){
			for (e in map.indices){
				if (map[b][k]==INF || map[k][e]==INF) continue
				val keiyu = map[b][k] + map[k][e]
				if (map[b][e] > keiyu) {
					map[b][e] = keiyu
				}
			}
		}
	}
	return map
}

Measured memory_bytes: 108604
#include<stdio.h>
#define f(i,k) for(i=k;i<5;i++)
int main(){
	int c[6];
	int i=4,j,t,p=0;
	for(;scanf("%d,%d,%d,%d,%d",&c[i--],&c[i--],&c[i--],&c[i--],&c[i--])!=EOF;i=4,p=0){
		f(i,0){f(j,i){if(c[i]>c[j]){
					t=c[i];c[i]=c[j];c[j]=t;
				}
			}
		}
		if(c[0]==c[3] || c[1] ==c[4] ){printf("four card\n");continue;}
		if(c[0]==c[2] || c[1] ==c[3] || c[2]== c[4]){
			for(i=0;i<2;i++)if(c[i]!=c[i+1])break;
			if(i==1){
				if(c[1]!=c[0]){printf("three card\n");continue;}
				printf("full house\n");continue;
			}
			if(i==0){printf("three card\n");continue;}
			if(c[3]!=c[4]){printf("three card\n");continue;}
			printf("full house\n");continue;
		}
		if(c[0]==c[1])p++;
		if(c[1]==c[2])p++;
		if(c[2]==c[3])p++;
		if(c[3]==c[4])p++;
		if(p==1){printf("one pair\n");continue;}
		else if(p==2){printf("two pair\n");continue;}
		if((c[0]+2==c[4]-2 && c[1]+1==c[3]-1) || (c[1]+2==c[0]+11 && c[2]+1==c[4]-1)){printf("straight\n");continue;}
		printf("null\n");
	}
	return 0;
}

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

int main(){
    long int x;
    cin>>x;
    long int ans;
    bool han=false;
    if(x==2)han=true;
    else {for(long int i=x;i<x+x;i++){
        bool can=false;
        for(int h=2;h<=sqrt(i);h++){
            if(i%h==0){
                can=false;
                break;
            }
            else can=true;

        }
        if(can){
            ans=i;
            break;
        }
    }
    }

    if(han)cout<<2<<endl;
    else cout<<ans<<endl;

}

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

constexpr int MAX_N = 100000;

int main() {
  int N;
  int A[MAX_N + 1];
  int B;
  std::cin >> N;
  for (int i = 0; i < N + 1; ++i) {
    std::cin >> A[i];
  }
  long long max_attack = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> B;
    int attack1 = std::min(A[i], B);
    B -= attack1;
    int attack2 = std::min(A[i + 1], B);
    A[i + 1] -= attack2;
    max_attack += attack1 + attack2;
  }
  std::cout << max_attack << std::endl;
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 2000100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();

  int k;
  cin >> k;
  string s;
  cin >> s;

  ll ans = 0;
  int len_total = s.length() + k;
  rep(i, s.length(), len_total+1){

    ans += (COM(len_total, i) * modpow(25, len_total-i, MOD))%MOD;
    ans = ans % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51128
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    for(ll i = round(sqrt(n)); i >= 1; --i) {
        if(n % i == 0) return cout << i + n / i - 2 << '\n', 0; 
    }
    assert(false);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cstring>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

void tc()
{
	int a,b;
	cin >> a >> b;
	cout << (a*b) << endl;
}

int main()
{
	fastio;
	int t; t=1;
	while(t--)
	{
		tc();
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
  string S;
  int N;
  int x = 0;
  cin >> S;
  N = S.length();
  string ans;

  for(int i = 0;i < (N-1)/2; i++){
    if(S[i] != S[N - 1 -i]){
      x = 1;
      break;
    }
  }

  if(x == 0){
      for(int i = 0;i < (N-1)/4; i++){
        if(S[i] != S[(N - 3) / 2 - i]){
          x = 1;
          break;
        }
        if(S[(N + 1) /2 + i] != S[N - 1 - i]){
          x = 1;
          break;
        }
      }
  }


if(x == 0){
  ans = "Yes";
}else{
  ans = "No";
}

  
  cout << ans;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll a[100005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 1;
	int up = 0;
	for (int i = 0; i < n-1; i++) {


		if (a[i] < a[i + 1]&&up == 2) {
			ans++;
			up = 0;
		}

		else if (a[i] > a[i + 1] && up == 1) {
			ans++;
			up = 0;
		}
		
		else if (a[i] < a[i + 1] && up == 0) {
			up = 1;
		}

		else  if (a[i] > a[i + 1] && up == 0) {
			up = 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ll N,K;
  cin >> N >> K;
  vector<P> A(K);
  vector<mint> imos(N+1,0);
  imos[0]+=1;
  imos[1]-=1;
  REP(i,K){
    cin >> A[i].first >> A[i].second;
  }

  REP(i,N-1){
    REP(j,K){
      if(i+A[j].fi<N){
        imos[i+A[j].fi]+=imos[i];
        if(i+A[j].se+1<=N){
          imos[i+A[j].se+1]-=imos[i];
        }else{
          imos[N]-=imos[i];
        }
      }
    }
    imos[i+1]+=imos[i];
  }

  cout << imos[N-1] << endl;
}


Measured memory_bytes: 4820
# AGC015a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, a, b = map(int, input().split())
    if b-a < 0:
        print(0)
        exit(0)
    if n == 1:
        if b != a:
            print(0)
        else:
            print(1)
        exit(0)
    print((n-2)*(b-a)+1)


if __name__ == '__main__':
    main()


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

const int DIM = 5e2 + 5;

char mat[DIM][DIM], ans1[DIM][DIM], ans2[DIM][DIM];

int main( void ) {

    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> ( mat[i] + 1 );
        
        for( int j = 1; j <= m; j ++ ) {
            if( mat[i][j] == '#' )
                ans1[i][j] = ans2[i][j] = '#';
            else
            if( j == 1 ) {
                ans1[i][j] = '#';
                ans2[i][j] = '.';
            }
            else
            if( j == m ) {
                ans1[i][j] = '.';
                ans2[i][j] = '#';
            }
            else
            if( i % 2 == 1 ) {
                ans1[i][j] = '#';
                ans2[i][j] = '.';
            }
            else {
                ans1[i][j] = '.';
                ans2[i][j] = '#';
            }
        }
    }
    
    for( int i = 1; i <= n; i ++ )
        cout << ( ans1[i] + 1 ) << "\n";
    cout << "\n";
    
    for( int i = 1; i <= n; i ++ )
        cout << ( ans2[i] + 1 ) << "\n";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String pattern1 = "[a-z]";
		Pattern p = Pattern.compile(pattern1);
		Matcher m = p.matcher(a);
		if (m.find()) {
			System.out.println("a");
		} else {
			System.out.println("A");
		}
		sc.close();
	}
}


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

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

    for (auto i = 0; i < s.size(); i++)
    {
        s[i] = (s[i] - 65 + n) % 26 + 65;
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) factors(N + 1, 0);
    const lint mod = 1000000007LL;
    lint ret = 1;
    for (int p = 2;p <= N; p++)
        if (factors[p] == 0) {
            int e = 0, t = N;
            while(t > 0) {
                e += t / p;
                t /= p;
            }

            ret = ret * (1 + e) % mod;
            for (int q = 2 * p;q <= N;q += p)
                factors[q] = p;
        }

    cout << ret << endl;
    return 0;
};


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

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scan = new Scanner(System.in);
        int size= 0;
        size=scan.nextInt();

        int[] arr = new int[size];
        for(int i=0;i<size;i++){
            arr[i]=scan.nextInt();
        }
        int[] ans = new int[size];
        for(int i=0;i<size;i++){
            ans[arr[i]-1]=i+1;
        }
        for(int c:ans){
            System.out.print(c+" ");
        }
    }
}


Measured memory_bytes: 59204
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N;
    cin>>N;
    v A(N);
    rep(i,0,N){
        cin>>A[i];
        A[i] *= -1;
    }
    sort(all(A));
    ll ans = 0;
    rep(i,0,N-1){
        ans += -A[(i+1)/2];
    }
    cout<< ans;
    return 0;
}

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

int w[55], b[55], r[55];
int n, m;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
        {
            if (s[j] == 'W')
                w[i]++;
            else if (s[j] == 'B')
                b[i]++;
            else
                r[i]++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        w[i + 1] += w[i];
        b[i + 1] += b[i];
        r[i + 1] += r[i];
    }
    int ans = 0;
    for (int i = 0; i + 2 < n; i++)
    {
        for (int j = i + 1; j + 1 < n; j++)
        {
            ans = max(ans, w[i] + (b[j] - b[i]) + (r[n - 1] - r[j]));
        }
    }
    cout << m * n - ans << endl;
}



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

int main(){
  while(1){
    int N, i, j, s = 0;
    scanf("%d", &N);
    if(N == 0){
      return 0;
    }
    vector<string> w(N);
    for(i = 0; i < N; i++){
      cin >> w[i];
      s += w[i].size();
    }
    vector<int> a(s + 1, 0);
    for(i = 0, j = 0; i < N; i++){
      a[j] = 1;
      j += w[i].size();
    }
    a[j] = 1;
/*    for(i = 0; i < a.size(); i++){
      printf("%d", a[i]);
    }
    printf("\n");
*/    s = 0;
    for(i = 0; i < N; i++){
//      printf("i = %d\n", i);
//      printf("s = %d\n", s);
      if(a[s] == 1 && a[s + 5] == 1 && a[s + 12] == 1 && a[s + 17] == 1 && a[s + 24] == 1 && a[s + 31] == 1){
        printf("%d\n", i + 1);
        break;
      }
      s += w[i].size();
    }
  }
}



Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
using namespace std;
int p[10000];
int c[500],e[500];
int dp[25000];
int main(){
	int n,m;
	cin>>m>>n;
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	for(int i=1;i<=m+11000;i++){
		dp[i]=100000000;
	}
	sort(p,p+m);
	for(int i=0;i<n;i++){
		cin>>c[i]>>e[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=m+11000;j>=c[i];j--){
			dp[j]=min(dp[j],dp[j-c[i]]+e[i]);
		}
	}
	int ans=0;
	int sum=0;
	for(int i=0;i<=m;i++){
		ans=max(sum-dp[i],ans);
		sum+=p[m-i-1];
	}
	int key=dp[m];
	for(int i=m+1;i<=m+11000;i++){
		key=min(key,dp[i]);
	}
	ans=max(ans,sum-key);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int w,a,b;
  cin >> w >> a >> b;
  int x=max(a,b),y=min(a+w,b+w);
  if(x-y>0) {
    cout << x-y << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

ll choco(ll H, ll W) {
  ll res = INFLL;
  FOR(h,1,H) {
    ll sa = h*W;
    { int h2 = (H-h)/2;
      ll sb = h2*W;
      ll sc = (H-h-h2)*W;
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      res = min(res,smax-smin);
    }
    { int w = W/2;
      ll sb = (H-h)*w;
      ll sc = (H-h)*(W-w);
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      res = min(res,smax-smin);
    }
  }
  return res;
}

int main () {
  ll H, W;
  cin >> H >> W;

  ll ans = min(choco(H,W),choco(W,H));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll h, w; cin >> h >> w;
    if (h > w) swap(h, w);
    if (h == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h % 2 == 1 && w % 2 == 1) {
        cout << (w * h + 1) / 2 << endl;
    } else {
        cout << (w * h) / 2 << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] inputval = inputval();
        int a = inputval[0];
        int b = inputval[1];
        int cnt = 0;
        for (int i=a; i<=b; i++){
            String si = Integer.toString(i);
            if (si.charAt(0) == si.charAt(4) && si.charAt(1) == si.charAt(3)){
                cnt++;
            }
        }
        System.out.println(cnt);


    }

}



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

int main() {
  
  int A;
  int B;
  int C;
  int D;
  
  cin >> A >> B >> C >> D;
  
  if ( A + B > C + D ) {
    
    cout << "Left" << endl;
  }
  
  else if ( A + B == C + D ) {
    
    cout << "Balanced" << endl;
  }
  
  else {
    
    cout << "Right" << endl;
  }
  
}


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

int main()
{
    int m,d;
    int ans=0;
    cin>>m>>d;
    for(int i=1;i<=m;i++)
    {
        for(int j=10;j<=d;j++)
        {
            int ge=j%10,shi=j/10;
            if(ge>=2&&shi>=2&&ge*shi==i)
            {
//                cout<<i<<" "<<j<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string S, T;
	cin >> S >> T;
	cout << T + S << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (0 until h).map {
        readLine()!!
    }

    val l = (0 until h).map { IntArray(w) { 0 } }
    val r = (0 until h).map { IntArray(w) { 0 } }
    val u = (0 until h).map { IntArray(w) { 0 } }
    val d = (0 until h).map { IntArray(w) { 0 } }

    for (i in (0 until h))
        for (j in (0 until w)) {
            // L
            if (grid[i][j] != '#') {
                l[i][j] = if (j == 0) {
                    1
                } else {
                    l[i][j - 1] + 1
                }
            }

            // R
            val j2 = w - 1 - j
            if (grid[i][j2] != '#') {
                r[i][j2] = if (j2 == w - 1) {
                    1
                } else {
                    r[i][j2 + 1] + 1
                }
            }

            // U
            if (grid[i][j] != '#') {
                u[i][j] = if (i == 0) {
                    1
                } else {
                    u[i - 1][j] + 1
                }
            }

            // D
            val i2 = h - 1 - i
            if (grid[i2][j] != '#') {
                d[i2][j] = if (i2 == h - 1) {
                    1
                } else {
                    d[i2 + 1][j] + 1
                }
            }
        }

    var ans = 0

    for (i in (0 until h))
        for (j in (0 until w)) {
            ans = Math.max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
        }

    println(ans)
}


Measured memory_bytes: 125564
#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;

int main(void) {
    int num;
    while(cin >> num, num != 0) {
        int ary[num + 1];
        ary[0] = 0;
        for(int r = 1; r <= num; r++) {
            int input; cin >> input;
            ary[r] = ary[r - 1] + input;
        }
        int max = INT_MIN;
        for(int r = 1; r <= num; r++) {
            for(int c = 0; c < r; c++) {
                int val = ary[r] - ary[c];
                if(val > max) max = val;
            }
        }
        
        cout << max << endl;
    }
    return(0);
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <cstdlib>

int main(void)
{

    // n カードの枚数
    // z Xの初期カード
    // w Xの初期カード
    int n=0, z=0, w=0;
    std::cin >> n >> z >> w;

    std::vector<int> cards(n);
    for(auto& card : cards)std::cin >> card;

    if(n==1){
        std::cout << abs(cards[0] - w) << std::endl;
    } else {
        // Xはすべて取るか、1枚残すかのいずれかを選択する
        int pattern_1 = abs(cards[n-2] - cards[n-1]);
        int pattern_2 = abs(cards[n-1] - w); 
            
        std::cout << (pattern_1 > pattern_2 ? pattern_1 : pattern_2) << std::endl;
    }   

    return 0;
}

Measured memory_bytes: 256
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i -1
    while j >= 0 and s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
    j = i
    if j == len(a) -1:
        return
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))


Measured memory_bytes: 24092
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();
    let mut a: Vec<i32> = readnc();
    a.sort();

    let mut rm = 0;
    let mut i = 0;
    while i < n {
        let mut j = i;
        while j < n && a[i] == a[j] {
            j += 1;
        }

        let cnt = (j-i) as i32;
        if a[i] < cnt {
            rm += cnt-a[i];
        } else if cnt < a[i] {
            rm += cnt;
        }
        i = j;
    }

    println!("{}", rm);
}


Measured memory_bytes: 8444
import sys

def test():

	counter = [0] * 26

	for inputs in sys.stdin:
		string = list(inputs)

		if len(string) == 0:
			break
	
		for i in range(len(string)):

			#Small character
			if ord('a') <= ord(string[i]) and ord(string[i]) <= ord('z'):
				counter[ord(string[i]) - 0x61] += 1

			#Big character
			elif ord('A') <= ord(string[i]) and ord(string[i]) <= ord('Z'):
				counter[ord(string[i]) - 0x41] += 1
		if i == 0:
			break

	for i in range(26):
		print(f"{chr(i+0x61)} : {counter[i]}")

if __name__ == "__main__":
	test()


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

#define MX 3005

int f[MX][MX] = {0};

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      f[i][j] = max(f[i-1][j], f[i][j-1]);
      if(s[i-1]==t[j-1]){
        f[i][j] = max(f[i][j], f[i-1][j-1]+1);
      }
    }
  }

  int x=n, y=m;
  string ans;
  while(x>0 && y>0){
    if(f[x][y] == f[x][y-1]){
      y--;
    }else if(f[x][y] == f[x-1][y]){
      x--;
    }else{
      ans += s[x-1];
      x--; y--;
    }
  }

  reverse(ans.begin(), ans.end());

  cout << ans;
  return 0;
}


Measured memory_bytes: 35456