akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int a[] = new int[n];
		long s[] = new long[n+1];
		for(int i = 0; i < n ; i++){
			a[i] = sc.nextInt();
			s[i+1] = s[i] + a[i];
		}
		
		
		long ans = s[n];
		for(int i=2; i < n ; i++){
			
			long pq = s[i];
			
			long pqmid = pq/2;
			
			int x = Arrays.binarySearch(s, pqmid);
			if(x < 0){
				x = -x-1;
			}
			
			long min = s[n];
			int xxx = 0;
			
			for(int xx = x-1; xx < x+2;xx++){
				if(xx < 1) continue;
				if(xx == i) continue;
				
				long p = s[xx];
				long q = pq-p;
				
				if(min > Math.abs(p-q)){
					min = Math.abs(p-q);
					xxx = xx; 
				}
			}
			
			
			long rs = s[n]-s[i];
			long rsmid = rs/2;
			
			int y = Arrays.binarySearch(s, pq+rsmid);
			if(y < 0){
				y = -y-1;
			}
			min = s[n];
			int yyy = 0;
			for(int yy = y-1; yy < y+2;yy++){
				if(yy >= n) continue;
				if(yy == i) continue;
				long r = (s[yy]-s[i]);
				long ss = rs - r;

				if(min > Math.abs(r-ss)){
					min = Math.abs(r-ss);
					yyy = yy; 
				}
			}
			
			long p = s[xxx];
			long q = pq-p;
			long r = (s[yyy]-s[i]);
			long ss = rs - r;
			
			long mmmax = Math.max(Math.max(r, ss),Math.max(p,q));
			long mmmin = Math.min(Math.min(r, ss), Math.min(p, q));
			
			ans = Math.min(ans, mmmax - mmmin);
		}
		System.out.println(ans);
				
	}
}


Measured memory_bytes: 86304
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

int main(){
	string s;cin>>s;ll K;cin>>K;
	ll N=s.size();
	ll dp[N+3][K+3][2]={};
	dp[0][0][0]=1;
	rep(i,N){
		rep(j,K+1){
			//使う
			dp[i+1][j][1]+=dp[i][j][1];
			//使わない
			dp[i+1][j+1][1]+=9*dp[i][j][1];

			ll d=s[i]-'0';
			if(d==0){
				dp[i+1][j][0]+=dp[i][j][0];
			}else{
				dp[i+1][j+1][0]+=dp[i][j][0];
				dp[i+1][j+1][1]+=(d-1)*dp[i][j][0];
				dp[i+1][j][1]+=dp[i][j][0];
			}
		}
	}
	cout<<dp[N][K][1]+dp[N][K][0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define lb(x,a) lower_bound(all(x),a)
#define ub(x,a) upper_bound(all(x),a)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  str s;
  cin >> s;
  ll n=s.size();
  if(s[n-1]=='s') cout << s << "es" << endl;
  else cout << s<< "s" << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k <= a) {
    	cout<<k<<"\n";
    } else if(k <= a + b){
    	cout<<a<<"\n";
    } else {
    	k = k - a - b;
    	cout<<a - k<<"\n";
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  int n,m;cin>>n>>m;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      int total = 10000 * i + 5000 * j;
      int rest = n - i - j;
      if (rest < 0) break;
      total += 1000 * rest;
      if (total == m){
        cout<<i<<' '<<j<<' '<<rest<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return 0;
}


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

int main(){
	int N, A, B;
	string S;
	cin >> N >> A >> B;
	cin >> S;
	int passJapan = 0;
	int passOversea = 0;
	for (int i = 0; i < N; i ++)
	{
		switch (S[i])
		{
		case 'a':
			if((passJapan + passOversea) < (A+B))
			{
				cout << "Yes" <<endl;
				passJapan ++;
			}else{
				cout << "No" << endl;
			}
			break;
		case 'b':
			if(((passJapan + passOversea) < (A + B)) && (passOversea < B)){
				cout << "Yes" <<endl;
				passOversea ++;
			}else{
				cout << "No" << endl;
			}
			break;
		case 'c':
		default:
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		int x; cin>>x;
		if(x>=400 and x<=599) cout<<8;
		if(x>=600 and x<=799) cout<<7;
		if(x>=800 and x<=999) cout<<6;
		if(x>=1000 and x<=1199) cout<<5;
		if(x>=1200 and x<=1399) cout<<4;
		if(x>=1400 and x<=1599) cout<<3;
		if(x>=1600 and x<=1799) cout<<2;
		if(x>=1800 and x<=1999) cout<<1;
	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s;
  cin >> s;
  int top    = (s[0] - '0') * 10 + (s[1] - '0');
  int bottom = (s[2] - '0') * 10 + (s[3] - '0');
  bool top_y = true, top_m = false, bot_y = true, bot_m = false;
  if (1 <= top && top <= 12) top_m = true;
  if (1 <= bottom && bottom <= 12) bot_m = true;
  if (top_y && bot_m) {
    if (top_m && bot_y) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  } else if (top_m && bot_y) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, grid[21][21], dp[21][1 << 21], mod = 1e9 + 7;

int solve(int ind, int mask){
    if(ind == n) return 1;
    int &ret = dp[ind][mask];
    if(ret != -1) return ret;
    ret = 0;
    for(int i = 0 ; i < n ; i++){
        if(grid[ind][i] && ((1 << i) & mask)){
            ret += solve(ind + 1, mask ^ (1 << i));
            if(ret >= mod) ret -= mod;
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            cin >> grid[i][j];
    cout << solve(0, (1 << n) - 1) << endl;
}


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

int main() {
    int l,r,d;cin>>l>>r>>d;
	if(d==1)
	    cout<<r-l+1<<"\n";
	else if(l==d && d==r && l==r)
	    cout<<"1"<<"\n";
	else
	    cout<<(r/d)-((l-1)/d)<<"\n";
	return 0;
}

Measured memory_bytes: 3524
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
 */
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        int e=sc.nextInt();
        int f=sc.nextInt();
        Queue<Integer> water=new ArrayDeque<>();
        Queue<Integer> sugar=new ArrayDeque<>();
        String ans=0+" "+0;
        double density=0;
        for (int i = 0; i<40 ; i++) {
            for (int j = 0; j<40 ; j++) {
                if((i*a+j*b)*100<=f)water.add((i*a+j*b)*100);
            }
        }
        for (int i = 0; i<3010 ; i++) {
            for (int j = 0; j<3010 ; j++) {
                if(i*c+j*d<=f)sugar.add(i*c+j*d);
            }
        }
        for (Integer j:water){
            for (Integer k:sugar){
                if((double)k/(double)(j+k)>=density&&j+k<=f&&k<=j/100*e){
                    density=(double)k/(double)(j+k);
                    ans=(j+k)+" "+k;
                }
            }
        }
        out.println(ans);
    }
}

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

int main()
{
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	x1 *= 1.0;
	x2 *= 1.0;
	y1 *= 1.0;
	y2 *= 1.0;
	printf("%lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
}

Measured memory_bytes: 1080
# -*- coding: utf-8 -*-
"""
Basic Data Structures - Stack
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_2_A&lang=jp

"""
n, q = map(int, input().split())
stacks = [[] for _ in range(n)]
for _ in range(q):
    op, t, x = (input() + ' 1').split()[:3]
    if op == '0':
        stacks[int(t)].append(x)
    elif op == '1':
        if stacks[int(t)]:
            print(stacks[int(t)][-1])
    else:
        if stacks[int(t)]:
            stacks[int(t)].pop()



Measured memory_bytes: 19848
import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		StringBuilder str = new StringBuilder ();
		
		final String word = scan.next();
		str.append(word);
		
		final String keyword = scan.next();
		scan.close();
		
		int i = str.indexOf(keyword);
		
		if (i != -1) {
			System.out.println(i);
			i = str.indexOf(keyword, i + 1);
			while (i != -1) {
				System.out.println(i);
				i = str.indexOf(keyword, i + 1);
			}
		}
		
	}
}



Measured memory_bytes: 26364
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
i=0
pl=0
v=[0]+[nil]*(n-1)
d=0
while true
  i+=1
  pl=a[pl]-1
  if i==k
    puts pl+1
    exit
  end
  if v[pl]==nil
    v[pl]=i
  else
    d=i-v[pl]
    break
  end
end
r=(k-v[pl])%d
puts v.index(v[pl]+r)+1


Measured memory_bytes: 30476
#include<algorithm>
#include <cstring>
#include <iostream>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<utility>
#include<stack>
#include <complex>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,c) for (__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(),(c).end();

#define MP make_pair
int dy[] = {-1,0,1,0};
int dx[] = {0,1,0,-1};

int score[5];
bool kieru[5][5];

int rensa(vector<vector<int> > field) {
  bool update = 1;
  int bonus = 1;
  int res = 0;
  while(update) {
    update = 0;
    memset(kieru,0,sizeof(kieru));

    REP(y,5) {
      REP(x,5) {
        int c = field[y][x];
        if (c == -1) continue;
        if (x+3<=5) {
          bool f = 1;
          for (int xx=x; xx<x+3; ++xx) {
            if (field[y][xx] != c) f = 0;
          }
          if (f) {
            for (int xx=x; xx<x+3; ++xx)
              kieru[y][xx] = 1;
          }
        }
        if (y+3<=5) {
          bool f = 1;
          for (int yy=y; yy<y+3; ++yy) {
            if (field[yy][x] != c) f = 0;
          }
          if (f) {
            for (int yy=y; yy<y+3; ++yy)
              kieru[yy][x] = 1;
          }
        }
      }
    }
    int tmp = 0;
    REP(y,5) REP(x,5) if (kieru[y][x])  {
      update = 1;
      tmp += score[field[y][x]];
      field[y][x] = -1;
    }
    res += tmp * bonus;
    bonus++;
    REP(x,5) {
      for (int y=3; y>=0; --y) {
        int yy = y+1;
        while(yy<5&&field[yy][x]==-1) {
          swap(field[yy-1][x],field[yy][x]);
          yy++;
        }
      }
    }
    // REP(y,5) {
    //   REP(x,5) cout << field[y][x] << " ";
    //   cout << endl;
    // }
  }
  return res;
}

int ans;
int n;

void go(int nest, int y, int x, vector<vector<int> > field) {
  int tmp = rensa(field);
  ans = max(ans, tmp);
  if (nest >=n) return;
  REP(d,4) {
    int yy = y+dy[d];
    int xx = x+dx[d];
    if (yy<0||yy>=5||xx<0||xx>=5) continue;
    vector<vector<int> > next(field);
    swap(next[y][x], next[yy][xx]);
    go(nest+1, yy, xx, next);
  }
}

void solve() {
  vector<vector<int> > field(5,vector<int>(5,0));
  
  for(int i=0; i<5; i++) {
    for(int j=0; j<5; j++) {
      cin>>field[i][j];
      field[i][j]--;
    }
  }
  for(int i=0; i<5; i++)
    cin>>score[i];
  REP(y,5) {
    REP(x,5) {
      go(0,y,x,field);
    }
  }
}


int main() {
    while(1) {
      cin>>n;
      if(n==-1)
        break;
      ans = 0;
      solve();
      cout << ans << endl;
    }
    return 0;
  
  }

Measured memory_bytes: 1220
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
signed main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> h(N);
    for(long long i=0; i<N; ++i) cin >> h[i];
    long long DP[N];
    DP[0] = 0;
    DP[1] = abs(h[0]-h[1]);
    for(long long i=1; i<N; ++i){
        long long res = (long long)1e10;
        for(long long j=1; i-j>=0 and j<=K; ++j){
            res = min(res, DP[i-j]+ abs(h[i]-h[i-j]));
        }
        DP[i] = res;
    }
    //for(long long i=0; i<N; ++i) cout << DP[i] << " ";
    //cout << endl;
    cout << DP[N-1] << "\n";
    return 0;
}

Measured memory_bytes: 1792
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int a, b;
	std::cin >> a >> b;
	if (a*b%2 == 1) {
		std::cout << "Odd\n";
	} else {
		std::cout << "Even\n";
	}
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char *s=(char *)malloc(sizeof(char)*(100000+1));
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int diff;
  int i;
  for(diff=1;diff<=2;diff++){
    for(i=0;i+diff<n;i++){
      if(s[i]==s[i+diff]){
	printf("%d %d\n",i+1,i+diff+1);
	return;
      }
    }
  }
  printf("-1 -1\n");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int n, m, k;

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int x = floor((double)(i + j) / k);
			int y = floor((double)(i - j) / k);
			if ((x & 1) && (y & 1))
			{
				printf("R");
			}
			if ((x & 1) && ! (y & 1))
			{
				printf("Y");
			}
			if (! (x & 1) && (y & 1))
			{
				printf("G");
			}
			if (! (x & 1) && ! (y & 1))
			{
				printf("B");
			}
		}
		puts("");
	}
	return 0;
}


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

string s, t;

int memo[3009][3009];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    cin >> t;

    for(int i = 0; i < 3009; i++){
        memo[i][0] = 0;
        memo[0][i] = 0;
    }
    s = '#'+s;
    t = '#'+t;
    int n = s.size();
    int m = t.size();
    for(int i = 1; i < n; i++){
        for(int j = 1; j < m; j++){
            memo[i][j] = max(memo[i-1][j], memo[i][j-1]);
            if(s[i] == t[j]){
                memo[i][j] = max(memo[i-1][j-1]+1, memo[i][j]);
            }
        }
    }
    int l = n-1;
    int c = m-1;
    string ans = "";
    while(l > 0 && c > 0){
        if(s[l] == t[c]){
            ans = s[l]+ans;
            l--;
            c--;
        }else if(memo[l-1][c] == memo[l][c]){
            l--;
        }else{
            c--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 70912
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        String S = sc.next();
        int K = sc.nextInt();
        char point = S.charAt(K-1);
        
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i) == point){
                System.out.print(S.charAt(i));
            }else{
                System.out.print("*");
            }
        }
    } 
}


Measured memory_bytes: 35752
#include<iostream>
using namespace std;
#include<cctype>
#include<cstring>

int main(){
    char mp[]="abcdefghijklmnopqrstuvwxyz";
    int mp_num[26]={},j=0;
    char target;
    while(cin>>target){
        if(isalpha(target)){
            target=tolower(target);
            int num=target-'a';
            mp_num[num]+=1;
        }
        ++j;
    }
    for(int i=0;i<26;i++){
        cout<<mp[i]<<" : "<<mp_num[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
D = inplt(n)

cnt = 0
ans = 'No'
for d1,d2 in D:
    if d1 == d2:
       cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = 'Yes'

print(ans)

Measured memory_bytes: 31112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 1000006;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    int N;
    cin >> N;
    int arr[N];
    for (int i = 0; i < N; i++) cin >> arr[i];
    sort(arr, arr + N);
    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (i != j) {
                int sum = arr[i] + arr[j];
                int ind = upper_bound(arr, arr + N, sum - 1) - arr;
                if (ind > j) ans += ind - j - 1;
                //cout << sum << ' ' << ind - 2 << '\n';
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;

int main() {

    int K,X;
    cin >> K >> X;
    for(int i=X-K+1;i<X+K;i++){
        cout << i;
        if(i!=X+K-1) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Int

const val P = 1000000007L

// Find (x, y, r) such that r = gcd(a,b) and ax + by = r.
fun extendedGCD(a: Long, b: Long): Triple<Long, Long, Long> {
  var x0 = 1L
  var y0 = 0L
  var z0 = a
  var x1 = 0L
  var y1 = 1L
  var z1 = b
  while (true) {
    if (z1 == 0L) return Triple(x0, y0, z0)
    val q = z0 / z1
    val x2 = x0 - q * x1
    val y2 = y0 - q * y1
    val z2 = z0 - q * z1
    x0 = x1
    x1 = x2
    y0 = y1
    y1 = y2
    z0 = z1
    z1 = z2
  }
}

fun inverseMod(a: Long, m: Long): Long {
  val (x, y, r) = extendedGCD(a, m)
  if (r != 1L) return 0  // No inverse.

  return (x + m) % m
}

fun timesMod(x: Long, y: Long): Long {
  return x * y % P
}

fun plusMod(x: Long, y: Long): Long {
  return (x + y) % P
}

fun minusMod(x: Long, y: Long): Long {
  return (x - y + P) % P
}

class FiniteField(xRaw: Long) {
  val x = if (xRaw >= 0) xRaw % P else (P - ((-xRaw) % P)) % P
  constructor(xi: Int): this(xi.toLong())
  operator fun plus(o: FiniteField) = FiniteField((x + o.x) % P)
  operator fun plus(o: Int) = this + FiniteField(o)
  operator fun minus(o: FiniteField) = FiniteField((x + P - o.x) % P)
  operator fun minus(o: Int) = this - FiniteField(o)
  operator fun times(o: FiniteField) = FiniteField((x * o.x) % P)
  operator fun times(o: Int) = this * FiniteField(o)
  operator fun div(o: FiniteField) = this * inverseMod(o.x, P).toInt()
  operator fun div(o: Int) = this * FiniteField(o)
  override fun toString() = x.toString()
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val factorialTable = Array(n, { FiniteField(0L) })
  factorialTable[0] = FiniteField(1)
  for (k in 1..(n - 1)) {
    factorialTable[k] = factorialTable[k - 1] * k
  }

  val fTable = Array(n, { k ->
    if (2 * k < n) FiniteField(0)
    else factorialTable[k] * factorialTable[k - 1] / factorialTable[2 * k - n]
  })

  var ans = FiniteField(0)
  for (k in 1..(n - 1)) {
    val count = fTable[k] - fTable[k - 1]
    ans += count * k
  }
  println(ans)
}

Measured memory_bytes: 145596
while 1:
    n,v=int(input()),0
    if n==0:break
    for _ in range(n):
        x,y,h,w=map(int,input().split())
        x=x+y+h
        if x<61 and w<3:v+=600
        elif x<81 and w<6:v+=800
        elif x<101 and w<11:v+=1000
        elif x<121 and w<16:v+=1200
        elif x<141 and w<21:v+=1400
        elif x<161 and w<26:v+=1600
    print(v)

Measured memory_bytes: 7652
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i,x,y,ans
    integer(int32), allocatable:: ball_num(:)
    logical,allocatable:: possible(:)

    
    read*, n,m
    allocate(ball_num(n), source=1)
    allocate(possible(n))
    possible(1) = .true.; possible(2:) = .false.

    do i=1,m
        read*, x,y
        ball_num(x)=ball_num(x)-1
        ball_num(y)=ball_num(y)+1
        possible(y) = possible(y) .or. possible(x)
        if (ball_num(x) == 0) possible(x) = .false.
    end do

    ans=0
    do i=1,n
        if(possible(i)) ans=ans+1
    end do

    print'(i0)', ans
end program name

Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc082/tasks/arc087_a
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]
c = Counter(nums)


ans = 0
for k, v in c.items():
    if k > v:
        ans += v
    else:
        ans += (v - k)
print(ans)

Measured memory_bytes: 68264
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	long long nN;
	cin >> nN;
	long long lnA = 1;
	long long lnB = nN;

	// 平方根に近い値で掛け算した方がx,yの合計数は小さな値になる。
	long long lnMid = floor(sqrt(nN));
	for (long long n = lnMid; n >=2 ; n--)
	{
		long long lnAmari = nN%n;
		if (0 != lnAmari)
			continue;

		lnA = n;
		lnB = nN / lnA;
		break;
	}

	long long lnAMove = lnA-1;
	long long lnBMove = lnB-1;
	long long lnMin = lnAMove + lnBMove;
	cout << lnMin;

	return 0;
}


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

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(500);
		StringBuilder d = new StringBuilder(".");
		StringBuilder s = new StringBuilder("#");
		StringBuilder k = new StringBuilder(50);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0;
		String u;
		while (++ww < 5) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 < (h = r.nextInt()) + (w = r.nextInt())) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			while (--h > 1) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 2003, inf = 1e9;
int n, p[N], val[N];
string a, b;
char cur[N];

int right_check(int pos, int k) {
	int res = 0;
	if (pos + k < n) {
		res = p[pos + k];
		if (pos > 0) {
			res -= p[pos - 1];
		}
	}	else {
		res = p[n - 1];
		if (pos > 0) {
			res -= p[pos - 1];
		}
		int r = (pos + k) % n;
		res += p[r];
	}
	return res > 0;
}

int left_check(int pos, int k) {
	int res = 0;
	if (pos - k >= 0) {
		res = p[pos];
		if (pos - k > 0) {
			res -= p[pos - k - 1];
		}
	}	else {
		res = p[pos];
		int l = (pos - k + n) % n;
		res += p[n - 1];
		if (l > 0) {
			res -= p[l - 1];
		}
	}
	return res > 0;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> a >> b;
	if (a == b) {
		cout << 0;
		return 0;
	}
	n = a.size();
	int ok = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] == '1') {
			ok |= 1;
		}
	}
	if (!ok) {
		cout << -1;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			p[i] = p[i - 1];
		}
		p[i] += (b[i] == '1');
	}
	int ans = inf;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cur[j] = a[(j + i) % n];
		}
		int m = 0;
		memset(& val, 0, sizeof(val));
		for (int j = 0; j < n; j++) {
			if (cur[j] == b[j]) {
				continue;
			}
			int l = -1, r = n - 1;
			while (l < r - 1) {
				int mid = l + r >> 1;
				if (right_check(j, mid)) {
					r = mid;
				}	else {
					l = mid;
				}
			}
			int R = r;
			l = -1, r = n - 1;
			while (l < r - 1) {
				int mid = l + r >> 1;
				if (left_check(j, mid)) {
					r = mid;
				}	else {
					l = mid;
				}
			}
			int L = r;
			val[L] = max(val[L], R);
			m++;
		}
		int mx = 0;
		for (int j = n - 1; j >= 0; j--) {
			int L = j, R = mx;
			ans = min(ans, i + 2 * (max(0, R - i) + L) + m);
			mx = max(mx, val[j]);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cur[j] = a[(j - i + n) % n];
		}
		int m = 0;
		memset(& val, 0, sizeof(val));
		for (int j = 0; j < n; j++) {
			if (cur[j] == b[j]) {
				continue;
			}
			int l = -1, r = n - 1;
			while (l < r - 1) {
				int mid = l + r >> 1;
				if (right_check(j, mid)) {
					r = mid;
				}	else {
					l = mid;
				}
			}
			int R = r;
			l = -1, r = n - 1;
			while (l < r - 1) {
				int mid = l + r >> 1;
				if (left_check(j, mid)) {
					r = mid;
				}	else {
					l = mid;
				}
			}
			int L = r;
			val[R] = max(val[R], L);
			m++;
		}
		int mx = 0;
		for (int j = n - 1; j >= 0; j--) {
			int R = j, L = mx;

			ans = min(ans, i + 2 * (max(0, L - i) + R) + m);
			mx = max(mx, val[j]);
		}
	}
	cout << ans;
}


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

const int MOD = 1e9 + 7;
int main() {
    int N; cin >> N;
    vector<int> C(N);
    for(int i = 0; i < N; ++i) cin >> C[i];
    sort(all(C));
    ll ret = 0;
    for(int i = 0; i < N; ++i) {
        ret = (ret + (ll)C[i] * (N - i + 1)) % MOD;
    }
    for(int i = 0; i < 2*N-2; ++i) {
        ret = (ret * 2) % MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))

class SegTree:
  def segfunc(self, x, y):
    return x + y
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(n):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res
qs = []
for i in range(Q):
  l, r = map(int, input().split())
  qs.append((l, r, i))
qs.sort(key = lambda x: x[1])
last = [0] * (N + 1)
fwk = SegTree(N + 1, 0, last)
for i in range(qs[0][1]): last[a[i]] = i + 1
for x in last:
  if x: fwk.update(x, fwk.query(x, x + 1) + 1)
#print(last)
res = [0] * Q
rlast = qs[0][1]
for l, r, i in qs:
  #print(l, r)
  if rlast == r:
    res[i] = fwk.query(l, r + 1)
  else:
    for x in range(rlast, r):
      if last[a[x]]: fwk.update(last[a[x]], fwk.query(last[a[x]], last[a[x]] + 1) - 1)
      fwk.update(x + 1, fwk.query(x + 1, x + 2) + 1)
      last[a[x]] = x + 1
    rlast = r
    res[i] = fwk.query(l, r + 1)
for r in res: print(r)

Measured memory_bytes: 180964
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

ll Kai(int t){
  ll r=1;
  FOR(i,2,t+1){
    r*=i;
    r%=MOD;
  }
  return r;
}

int main(){

  CIN(n,m);
  if(abs(n-m)>1){COUT(0);return 0;}

  ll ans =((Kai(n)%MOD)*(Kai(m)%MOD))%MOD;
  if(n==m)ans*=2;
  COUT(ans%MOD);


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,ans,a[233333];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    std::sort(a,a+n);
    for(int i=0;i<n;i++)ans+=(a[i]==a[i-1]);
    printf("%d\n",n-ans-(ans%2));
}

Measured memory_bytes: 640
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;}
ll s[N];
int main()
{
	ll n,p,i,j,k;
	cin >> n;
	for(i = 1;i <= n;i++)
		cin >> s[i];
	ll maxx = 0;
	ll sum = 0,flag = 1;
	for(i = 1;i <= n;i++)
	{
		if(s[i]&1)
			return 0*puts("first");
	}
		cout<<"second"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << " " << 2*(a+b) << endl;
}


Measured memory_bytes: 3104
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-7;
const double PI  = acos(-1.0);

#define CH(a) ((a)+'A')
#define IND(a) ((a)-'A')

bool dfs(vvi &g,vi used,int index){
	used[index]=1;
	REP(i,27){
		if(g[index][i]){
			if(used[i]){
				return false;
			}
			if(!dfs(g,used,i)){
				return false;
			}
		}
	}
	return true;
}

int main(){
	int datasets;
	cin>>datasets;
	REP(data,datasets){
		int h,w;
		cin>>h>>w;
		vs f(h);
		REP(i,h){
			cin>>f[i];
		}
		vector<pii> minimum(26,make_pair(INT_MAX,INT_MAX)),maximum(26,make_pair(INT_MIN,INT_MIN));
		REP(i,h){
			REP(j,w){
				REP(c,26){
					if(f[i][j]==CH(c)){
						if(minimum[c].first>i){
							minimum[c].first=i;
						}
						if(minimum[c].second>j){
							minimum[c].second=j;
						}
						if(maximum[c].first<i){
							maximum[c].first=i;
						}
						if(maximum[c].second<j){
							maximum[c].second=j;
						}
					}
				}
			}
		}
		vvi g(27,vi(27));
		REP(i,26){
			g[26][i]=1;
		}
		REP(c,26){
			FOR(i,minimum[c].first,maximum[c].first+1){
				FOR(j,minimum[c].second,maximum[c].second+1){
					if(f[i][j]!=CH(c)){
						if(f[i][j]=='.'){
							g[c][26]=1;
						}else{
							g[c][IND(f[i][j])]=1;
						}
					}
				}
			}
		}
		bool ok=true;
		REP(i,27){
			vi used(27);
			if(!dfs(g,used,i)){
				ok=false;
				break;
			}
		}
		cout<<(ok?"SAFE":"SUSPICIOUS")<<endl;
	}
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <stdlib.h>
#define int long long

int max(int a, int b){
	return a >= b ? a : b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int f(int k, int A){
	if(k < A){
		return k;
	}
	else{
		return k + 1;
	}
}

int can_make(int x, int A, int B){
	int k, ans = 0;
	k = min(x, max(1, x / 2));
	ans = max(ans, f(k, A) * f(x - k + 1, B));
	k = min(x, max(1, x / 2 + 1));
	ans = max(ans, f(k, A) * f(x - k + 1, B));
	k = min(x, max(1, x / 2 + 2));
	ans = max(ans, f(k, A) * f(x - k + 1, B));
	if(ans < A * B){
		return 1;
	}
	else{
		return 0;
	}
}

signed main(){
	int Q, A, B, q;
	scanf("%lld", &Q);
	int *ans = (int *)malloc(sizeof(int) * Q);
	for(q = 0; q < Q; q++){
		scanf("%lld%lld", &A, &B);
		int l = 0, h, r = 3000000010;
		while(r - l > 1){
			h = (l + r) / 2;
			if(can_make(h, A, B) == 1){
				l = h;
			}
			else{
				r = h;
			}
		}
		ans[q] = l;
	}
	for(q = 0; q < Q; q++){
		printf("%lld\n", ans[q]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0; cin>>n;
vector<int> b(n-1);
for(int i=0;i<n-1;i++){
    cin>>b[i];
}
ans+=b[0];
for(int i=0;i<n-2;i++){
    ans+=min(b[i],b[i+1]);
}
ans+=b[n-2];
cout<<ans;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for(int i=0; i<n; i++){
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

//入力
int n;
int a[100100], b[100100], c[100100];
int dp[100010][3];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0; i < 3; i++)
    {
        dp[0][i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
    }
    int ans = max(max(dp[n][0], dp[n][1]), dp[n][2]);
    printf("%d\n", ans);
}

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

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


int main()
{
    int N;
    cin >> N;
    vector<long long> a(N);
    REP(i, N) cin >> a[i];

    long long all = 0;
    REP(i, N){
        all ^= a[i];
    }
    REP(i, N) cout << (all^a[i]) << endl;

    return 0;
}

Measured memory_bytes: 4844
using System;
using System.Linq;

namespace id_0532cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var aWorkTime = new DateTime(2018, 7, 11, a[3], a[4], a[5]) - new DateTime(2018, 7, 11, a[0], a[1], a[2]);
            var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var bWorkTime = new DateTime(2018, 7, 11, b[3], b[4], b[5]) - new DateTime(2018, 7, 11, b[0], b[1], b[2]);
            var c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var cWorkTime = new DateTime(2018, 7, 11, c[3], c[4], c[5]) - new DateTime(2018, 7, 11, c[0], c[1], c[2]);

            Console.WriteLine("{0} {1} {2}", aWorkTime.Hours, aWorkTime.Minutes, aWorkTime.Seconds);
            Console.WriteLine("{0} {1} {2}", bWorkTime.Hours, bWorkTime.Minutes, bWorkTime.Seconds);
            Console.WriteLine("{0} {1} {2}", cWorkTime.Hours, cWorkTime.Minutes, cWorkTime.Seconds);

        }
    }
}



Measured memory_bytes: 9508
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

    ret = []
    for i in range(K + 1):
        if i == 0:
            ret.append(7 % K)
        else:
            ret.append((ret[i - 1] * 10 + 7) % K)
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 149732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double a, b, c, d, e, f;
		double x, y;

		Scanner scan = new Scanner(System.in);

		while ((scan.hasNext())) {

			a = Double.parseDouble(scan.next());
			b = Double.parseDouble(scan.next());
			c = Double.parseDouble(scan.next());
			d = Double.parseDouble(scan.next());
			e = Double.parseDouble(scan.next());
			f = Double.parseDouble(scan.next());

			y = (a * f - c * d) / (a * e - b * d);
			x = (c - b * y) / a;

			System.out.printf("%.3f %.3f\n", x, y);

		}
	}

}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int prize=0;
	if(n==1)prize+=300000;
	if(m==1)prize+=300000;
	if(n==2)prize+=200000;
	if(m==2)prize+=200000;
	if(n==3)prize+=100000;
	if(m==3)prize+=100000;
	if(n==1&&m==1)prize+=400000;
	cout<<prize<<'\n';
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

even = [a[i] for i in range(1,n,2)]
odd = [a[i] for i in range(0,n,2)]

if n % 2 == 0:
  print(*(even[::-1]+odd))
else:
  print(*(odd[::-1]+even))

Measured memory_bytes: 30900
#include "bits/stdc++.h"
//#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define fr(i , a , b) for(int  i = a ; i <= b ; i++)
#define all(v) v.begin() , v.end()
#define mod  1000000007
#define N 300005
#define mod1 1000000007
#define mod2 1000000009
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n" 
#define mid  (s+e)/2
#define MAX 10000007
//const int inf = (int)1e18 + 10;;

int dp[3003][3003 ];
signed main(){
  fast;
  
  //freopen("input.txt" , "r" , stdin);
  //freopen("output.txt" , "w" , stdout);
  

    string s , t  , ans;
    cin >>s >> t;
    int n = s.length();
    int m = t.length();
       for(int i = 0; i <= n ; i++){
            for(int j = 0 ; j <= m ; j++){
                   if(i == 0 || j == 0) {
                     dp[i][j] = 0;
                     continue;
                   }

                   dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);

                   if(s[i-1] == t[j-1]){
                       dp[i][j] = max( dp[i][j] , 1 + dp[i-1][j-1] );
                   }
            }
       }

       int i = n , j = m;
       while(i > 0 &&  j >  0){
              if(s[i-1] == t[j-1])
                ans += s[i-1] , i-- , j--;
              else if(dp[i-1][j] > dp[i][j-1])
                i--;
              else j--;

       } 

       reverse(ans.begin() , ans.end());
       cout << ans << endl;



 }

Measured memory_bytes: 70656
a, b, c, x, y = map(int, input().split())

z = max(x,y) * 2
min_sum = c * z

for i in range(z):
    r = max(0, y - i) * b
    t = max(0, x - i) * a
    sum = c * i * 2 + r + t
    if sum < min_sum:
        min_sum = sum

print(min_sum)

Measured memory_bytes: 3060