akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
//		String baseUrl = "C:\\Users\\kuriyama.akira\\git-repository\\hobby\\AIZU_ONLINE_JUDGE\\Java\\";
//		String filePath = baseUrl +  "inp_itp_1_9_a.txt";
//		FileInputStream fis = null; 
//		try { 
//			fis = new FileInputStream(new File(filePath));
//		}catch(FileNotFoundException e){
//			e.printStackTrace();
//		}
//		BufferedReader br = new BufferedReader(new InputStreamReader(fis));
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> ti = new ArrayList<String>();
		int cnt = 0;
		
		String W = "";
		try {
			W = br.readLine(); 
			String tmp;
			while((tmp = br.readLine()) != null) {
				if(tmp.equals("END_OF_TEXT"))break;
				
				List<String> line = Arrays.asList(tmp.split("\\s"));
				ti.addAll(line);
				ti = ti.stream().map(t -> t.toLowerCase()).collect(Collectors.toList());
			}
			br.close();
		}catch(IOException e) {
			e.printStackTrace();
		}

		for(String hoge: ti) {
			if(hoge.equals(W))
				cnt++;
		}
		System.out.println(cnt);		
	}
}



Measured memory_bytes: 31124
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main(int argc, char const *argv[])
{
	string str;
	int q=0;
	string sub1,sub4,rev;
	int sub2,sub3;
	cin >> str;
	cin >> q;

	for (int i = 0; i < q; ++i)
	{	
		cin >> sub1;
		if (sub1 == "print")
		{
			cin >> sub2 >> sub3;
			cout << str.substr(sub2, sub3-sub2+1) << endl;
		}
		else if (sub1 == "reverse")
		{
			cin >> sub2 >> sub3; 
			rev = str.substr(sub2, sub3-sub2+1); 
			reverse(rev.begin(), rev.end());
			str = str.replace(sub2, rev.size(), rev);
		}
		else if (sub1 == "replace")
		{
			cin >> sub2 >> sub3 >> sub4; 
			str = str.replace(sub2, sub3 - sub2 +1, sub4);
		}

	}
	return 0;
}



Measured memory_bytes: 3148
a = [int(input()) for i in range(5)]
mi = 10
count = 0
for i in range(5):
    if a[i] % 10 != 0:
        if mi > (a[i]%10):
            mi = a[i] % 10
        a[i] += (10 - a[i]% 10)
    count+=a[i]
print(count-10+mi)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define ff first
#define ss second
int main() {
	ios::sync_with_stdio(0);
	int len1, len2;
	string A;
	string B;
	cin >> A >> B;
	len1 = A.length() + 1;
	len2 = B.length() + 1;

	int dptable[len1][len2];
	memset(dptable, 0, sizeof(dptable));

	for (int i = 1; i < len1; i++) {
		for (int j = 1; j < len2; j++) {
			if (A[i - 1] == B[j - 1]) {
				dptable[i][j] = dptable[i - 1][j - 1] + 1;
			}
			else {
				dptable[i][j] = max(dptable[i - 1][j], dptable[i][j - 1]);
			}
		}
	}

	string answer = "";

	int i = len1 - 1;
	int j = len2 - 1;
	while (i > 0 && j > 0) {
		if (dptable[i][j] > max(dptable[i - 1][j], dptable[i][j - 1])) {
			answer = A[i - 1] + answer;
			i--;
			j--;
		}
		else if (dptable[i - 1][j] > dptable[i][j - 1]) {
			i--;
		}
		else {
			j--;
		}
	}

	cout << answer << endl;
	return 0;
}	

Measured memory_bytes: 35456
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

int change_ans(int i,int n,bool f){
    int ret=0;
    if(f){
        int fr=ans[i];
        ret+=s[i][n];
        ret-=s[i][fr];
        int cf=0;
        int ct=1;
        for(int j=i+1;j<=D;j++){
            if(fr==ans[j]) break;
            cf++;
        }
        for(int j=i;j<=D;j++){
            if(n==ans[j]) break;
            ct++;
        }
        ret+=c[fr]*cf;
        ret-=c[n]*ct;
    }
    ans[i]=n;
    //cout<<ret<<endl;
    return ret;
}

void solve_C(){
    int M;
    cin>>M;
    int man=man_calc(false);
    //cout<<man<<endl;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        int cng=change_ans(from,to,true);
        man+=cng;
        cout<<man<<endl;
    }
}

void random_solve(){
    int seed=1234;
    int cnt=1000000;
    srand(seed);
    ans_ran();
    for(int i=0;i<=cnt;i++){
        int bef=man_calc(false);
        int ci=rand()%D+1;
        int tn=rand()%26+1;
        int fn=ans[ci];
        int cng=change_ans(ci,tn,true);
        if(cng<0){
            change_ans(ci,fn,false);
        }
    }
    ans_disp();
    //cout<<man_calc(false)<<endl;
}

signed main(){
    inp();
    random_solve();
    //ans_inp();
    //solve_C();
    //random_solve();
    return 0;
}



Measured memory_bytes: 3228
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input().strip())
  for c in input().strip():
    c = chr((ord(c) - ord('A') + n) % 26 + ord('A'))
    print(c, end='')
  print()

if __name__=='__main__':
  main()

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){   
    int n;
    cin >> n;
    if(n >= 400 && n <= 599){
    	cout << 8;
    }
    else if(n >= 600 && n <= 799){
    	cout << 7;
    }
    else if(n >= 800 && n <= 999){
    	cout << 6;
    }
    else if(n >= 1000 && n <= 1199){
    	cout << 5;
    }
    else if(n >= 1200 && n <= 1399){
    	cout << 4;
    }
    else if(n >= 1400 && n <= 1599){
    	cout << 3;
    }
    else if(n >= 1600 && n <= 1799){
    	cout << 2;
    }
    else if(n >= 1800 && n <= 1999){
    	cout << 1;
    }

}

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

class Node implements Comparable<Node>{
    int i;
    int d;
    public Node(int i, int d){
        this.i = i;
        this.d = d;
    }
    public int compareTo(Node n){
        return Integer.compare(this.d, n.d);
    }
}

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter output = new PrintWriter(System.out);
        int N = Integer.parseInt(input.readLine());
        StringTokenizer st = new StringTokenizer(input.readLine());
        int[] arr = new int[N];
        boolean[] visited = new boolean[N];
        for(int i = 0; i<N; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        PriorityQueue<Node> pq = new PriorityQueue<Node>();
        pq.add(new Node(1, Math.abs(arr[0] - arr[1])));
        if(N>2)
            pq.add(new Node(2, Math.abs(arr[0] - arr[2])));

        while(!pq.isEmpty()){
            Node n = pq.poll();
            if(visited[n.i]) continue;
            visited[n.i] = true;
            if(n.i == N-1){
                output.println(n.d);
                break;
            }
            if(n.i<N-1)
                pq.add(new Node(n.i+1, n.d + Math.abs(arr[n.i] - arr[n.i+1])));
            if(n.i<N-2)
                pq.add(new Node(n.i+2, n.d + Math.abs(arr[n.i] - arr[n.i+2])));
        }
        output.close();
    }
}

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

int main() {
    long long K, A, B; cin >> K >> A >> B;
    if (B-A <= 2 || K < A-1) cout << K+1 << endl;
    else {
        long long res = A;
        K -= A-1;
        if (K % 2 == 1) ++res, --K;
        res += (B-A) * (K/2);
        cout << res << endl;
    }
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
h = [intl() for _ in range(n)]

dp = [[0]*3 for _ in range(n)]
for i in range(n):
    if i == 0:
        dp[i][0] = h[i][0]
        dp[i][1] = h[i][1]
        dp[i][2] = h[i][2]
    else:
        for j in range(3):
           dp[i][0] = max( dp[i-1][1] + h[i][0], dp[i-1][2] + h[i][0] )
           dp[i][1] = max( dp[i-1][0] + h[i][1], dp[i-1][2] + h[i][1] )
           dp[i][2] = max( dp[i-1][0] + h[i][2], dp[i-1][1] + h[i][2] )
print( max(dp[n-1]) )

Measured memory_bytes: 47344
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Tue Jul 21 18:31:19 JST 2020
 **/

void solve() {
    Int n;
    std::cin >> n;
    std::vector<std::vector<Int>> bl(n), br(n);
    Int ans = 0;
    REP(i, n) {
        Int k, l, r;
        std::cin >> k >> l >> r, k--;
        ans += std::min(l, r);
        if (l > r) {
            bl[k].push_back(l - r);
        } else {
            if (n - 2 - k >= 0) br[n - 2 - k].push_back(r - l);
        }
    }
    for (auto& v : {bl, br}) {
        std::priority_queue<Int, std::vector<Int>, std::greater<Int>> pq;
        REP(i, n) {
            for (Int x : v[i]) pq.push(x);
            while (pq.size() > i + 1) pq.pop();
        }
        while (pq.size()) ans += pq.top(), pq.pop();
    }
    std::cout << ans << "\n";
}
signed main() {
    Int T;
    std::cin >> T;
    while (T--) solve();
}


Measured memory_bytes: 33108
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (ll)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../CLionProjects/Codeforces/library/DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
int MAX() {return -INF;}
int MIN() {return INF;}
template<typename T, typename... Args>
T MAX(T a, Args... args) {return max(a, MAX(args...));}
template<typename T, typename... Args>
T MIN(T a, Args... args) {return min(a, MIN(args...));}

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;


int main(void) {    
#ifdef LOCAL_DEFINE
    freopen("in.txt", "r", stdin);
#endif
    
    int t; 
    scanf("%d", &t);
    while (t--) {
        vi sides(3);
        scanf("%d %d %d", &sides[0], &sides[1], &sides[2]);
        sort(all(sides));
        if (sides[2] * sides[2] == sides[1] * sides[1] + sides[0] * sides[0]) printf("YES\n");
        else printf("NO\n");
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,P;
    cin >> N >> P;
    auto A = InputVec(N);
    ll memo[N + 1][2];
    for (int yi = 0; yi < 2; ++yi) {
        for (int xi = 0; xi < N + 1; ++xi) {
            memo[xi][yi] = 0;
        }
    }
    memo[0][0] = 1;
    memo[0][1] = 0;
    for (int i = 0; i < N; ++i) {
        if(A[i] % 2 == 0){
            memo[i+1][0] = memo[i][0] * 2;
            memo[i+1][1] = memo[i][1] * 2;
        }else{
            memo[i+1][0] = memo[i][0] + memo[i][1];
            memo[i+1][1] = memo[i][0] + memo[i][1];
        }
    }
    cout << memo[N][P] << endl;
    

}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100;
int n,x;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> x;

  int c = 1;
  int d = 0;
  forn(i,n) {
    int l; cin >> l;
    d += l;
    if (d <= x) c++;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        string sn;
        cin>>sn;
        int type=0;
        if(sn[0]=='>'&&sn[1]==39)type=1;
        if(sn[0]=='>'&&sn[1]=='^')type=2;
        int flg=1;
        if(type==1){
            int cou=0;
            int aftercou=0;
            int p;
            for(int j=2;j<sn.size();j++){
                if(sn[j]=='=')cou++;
                else if(sn[j]=='#'){
                    p=j;
                    break;
                }
                else{
                    flg=0;
                    goto syutu;
                }
            }
            for(int k=p+1;k<sn.size();k++){
                if(sn[k]=='=')aftercou++;
                else if(sn[k]=='~'&&k==sn.size()-1){
                    if(cou!=aftercou)flg=0;
                    goto syutu;
                }
                else{
                    flg=0;
                    goto syutu;
                }
            }
            if(sn[sn.size()-1]!='~')flg=0;
syutu:
            if(flg&&cou)puts("A");
            else puts("NA");
        }
        else if(type==2){
            for(int j=2;j<sn.size()-1;j+=2){
                if(sn[j]=='~'&&sn[j+1]=='~'&&j!=2)break;
                if(!(sn[j]=='Q'&&sn[j+1]=='='))flg=0;
            }
            if(sn[sn.size()-2]!='~'||sn[sn.size()-1]!='~')flg=0;
            if(flg)puts("B");
            else puts("NA");
        }
        else puts("NA");
    }
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
using namespace std;
int mod = 1E+9 + 7;


int main() {
	int n;
	cin >> n;
	
	int num[3] = {};
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int count = 0;
		for (int j = 0; j < 3; j++) {
			if (num[j] == a) {
				if(!count) num[j]++;
				count++;
			}
		}
		ans *= count;
		ans %= mod;
	}
	cout << ans << endl;
	
}

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

int main(){
  double l;
  cin >> l;
  double ans = l * l * l / 27.0;
  printf("%.9lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
n=int(input())
cards=[]
for i in range(n):
    a,b=map(int,input().split())
    cards.append((a,b))

memo=[[-1 for i in range(n+1)]for j in range(n+1)]
def getans (l,r,cards):
    if(memo[l][r]==-1):
        if(l+1==r):
            memo[l][r]=0
        else:
            ans=1<<32
            for m in range(l+1,r):
                cost=cards[l][0]*cards[m-1][1]*cards[m][0]*cards[r-1][1]+getans(l,m,cards)+getans(m,r,cards)
                ans=min(ans,cost)
            memo[l][r]=ans
    return memo[l][r]

print(getans(0,n,cards))

Measured memory_bytes: 7888
/*input
2
1 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn],b[maxn];

set<int> st;

int med(int a,int b,int c){
	return a+b+c-max({a,b,c})-min({a,b,c});
}
int ans[maxn]; 
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) a[i]=i*n+n;
	REP(i,n) b[i]=n*n-i*n;

	REP(i,n){
		int tmp;
		cin>>tmp;
		tmp--;
		b[tmp]+=i;
	}
	REP(i,n) cout<<a[i]<<" \n"[i==n-1];
	REP(i,n) cout<<b[i]<<" \n"[i==n-1];
	return 0;
}


Measured memory_bytes: 2816
import queue


class Edge:
    def __init__(self, _to, _cost):
        self.to = _to
        self.cost = _cost


def bellman(n, graph, start):
    dist = [0 if i == start else float('inf') for i in range(n)]

    for i in range(n):
        for v in range(n):
            for e in graph[v]:
                if dist[v] == float('inf') or dist[e.to] <= dist[v] + e.cost:
                    continue

                dist[e.to] = dist[v] + e.cost

                if i == n - 1:
                    return None

    return dist


def main():
    n, m, s = map(int, input().split())
    graph = [[] for _ in range(n)]

    for _ in range(m):
        data = list(map(int, input().split()))

        graph[data[0]].append(Edge(data[1], data[2]))

    ans = bellman(n, graph, s)

    if ans is None:
        print("NEGATIVE CYCLE")
    else:
        for i in range(n):
            print(ans[i] if ans[i] != float('inf') else "INF")
        return


if __name__ == '__main__':
    main()



Measured memory_bytes: 7608
def main():
    S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K=int(input())
    print(S[K-1])
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;cin>>h>>w;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    bool key=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                if(s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'){
                    key=false;
                }
            }
        }
    }
    if(key) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import deque

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
nps=[0]*N

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

arr=[[]]

for i,np in enumerate(nps):
    if np==0:
        arr[-1].append(i)

while arr[-1]:
    arr.append([])
    for src in arr[-2]:
        for dst in edges[src]:
            nps[dst]-=1
            if nps[dst]==0:
                arr[-1].append(dst)

gens=[0]*N
for gen, a in enumerate(arr):
    for n in a:
        gens[n]=gen

parents=[-1]*N
q=deque(arr[0])
while q:
    src = q.popleft()
    for dst in edges[src]:
        if gens[dst]-gens[src]==1:
            parents[dst]=src+1
            q.append(dst)

for p in parents:
    print(p if p>0 else 0)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string a, b, ans;
  cin >> a >> b;

  int aa = a.length();
  int bb = b.length();
  int difw = abs(aa - bb);

  if (a.length() < b.length())
    for (int i = 0; i < difw; ++i) a = '0' + a;
  else if (a.length() > b.length())
    for (int i = 0; i < difw; ++i) b = '0' + b;

  if (a > b)
    ans = "GREATER";
  else if (a < b)
    ans = "LESS";
  else
    ans = "EQUAL";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
string s,t;
int dp[3010][3010];
int getans(int i,int j)
{
	if(i>=s.size())
	{
		return 0;
	}
	if(j>=t.size())
	{
		return 0;
	}
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	int ans=0;
	if(s[i]==t[j])
	{
		 ans=1+getans(i+1,j+1);

	}
	else
	{
		 ans=max(getans(i+1,j),getans(i,j+1));
	}
	return dp[i][j]=ans;
}
void path(int i,int j)
{
		if(i>=s.size())
	{
		return ;
	}
	if(j>=t.size())
	{
		return ;
	}
	int d=getans(i,j);
	if(s[i]==t[j])
	{
		cout<<s[i];
		return path(i+1,j+1);
	}
	else
	{
		if(d==getans(i+1,j))
		{
			return path(i+1,j);
		}
		return path(i,j+1);
	}
}
int main(){
cin>>s>>t;
	memset(dp,-1,sizeof(dp));
int v=getans(0,0);
path(0,0);
}




Measured memory_bytes: 39380
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Helix(sc.next());
  }

  static void Helix(String s){
    if(s.equals("A")){
      System.out.println("T");
    }else if(s.equals("T")){
      System.out.println("A");
    }else if(s.equals("G")){
      System.out.println("C");
    }else if(s.equals("C")){
      System.out.println("G");
    }
  }
}

Measured memory_bytes: 20436
# https://atcoder.jp/contests/abc171/tasks/abc171_c

TBL = [*'a'..'z'].freeze
n = N = gets.to_i

ans = ''
while n.positive?
  k = (n - 1) % 26
  ans = TBL[k] + ans
  n = (n - k - 1) / 26
end

puts ans


Measured memory_bytes: 14328
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

int main()
{
	LL n;
	cin >> n;
	vector<LL> a(n);
	for (auto &e : a) {
		cin >> e;
	}
 	
	bool poss = true;
	for (LL i = 0; i < n; ++i) {
		if (a[i] %2 == 0) {
			if (a[i] %3 == 0 || a[i] % 5 == 0) {
				
			}
			else {
				poss = false;
			}
		}
	}

	if (poss) {
		cout << "APPROVED\n";
	}
	else {
		cout << "DENIED\n";
	}

	
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,dp[1000],m,a;
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    for(int i=0;i<n;i++)dp[i]=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>a;
            dp[j]+=a;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    }
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<pair<int,int>> jobs;
    for (int i=0;i<N;++i){
        int A,B; cin >> A >> B;
        jobs.emplace_back(A,B);
    }
    sort(jobs.begin(),jobs.end());
    priority_queue<int> pq;
    int ans=0,s=0;
    for (int day=1;day<=M;++day){
        for (int i=s;i<N;++i){
            if (jobs[i].first==day) pq.push(jobs[i].second);
            else {s=i; break;}
        }
        if (!pq.empty()){ans+=pq.top(); pq.pop();}
    }
    cout << ans << endl;
}

Measured memory_bytes: 1908
# https://atcoder.jp/contests/abc067/tasks/abc067_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    A, B = map(int, input().split())
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print('Possible')
    else:
        print('Impossible')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
// AOJ 0297 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0297)
#include<cstdio>
#define rep(i,a) for(int i=0;i<(a);++i)

int N;

int main()
{
	scanf( "%d", &N );
	rep( i, N )
	{
		int K, P;
		scanf( "%d%d", &K, &P );

		printf( "%d\n", K%P?K%P:P );
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int P[10000];
void init(int N) {
  for (int i = 0; i < N; i++) {
    P[i] = i;
  }
}

int root(int a) {
  if(P[a] == a)
    return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b) {
  return root(a) == root(b);
}

void unite(int a, int b) {
  P[root(a)] = root(b);
}

int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      unite(x, y);
    } else {
      cout << is_same_set(x, y) << endl;
    }
  }
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    string s1,s2;
    rep(i,s.size()){
        if(i%2==0){s1.push_back('1');s2.push_back('0');}
        else{s2.push_back('1');s1.push_back('0');}
    }
    int r1=0,r2=0;
    rep(i,s.size()){
        if(s[i]!=s1[i])r1++;
        if(s[i]!=s2[i])r2++;
    }
    co(min(r1,r2));
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;


#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)


#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define MAX                     1e9 + 9

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


int main()
{
    taratari

    int n;
    cin>>n;

    int a[n];
    int b[n];

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

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

    int boro=0;

    for(int i=0;i<n;i++)
    {
       if(a[i]>b[i])
       {
           boro+=(a[i]-b[i]);
       }
    }

    cout<<boro;


    return 0;

}



Measured memory_bytes: 3608
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))*.1591545-.5,(@b=sort{$a<=>$b}map+(/ /*atan2$'-$y,$`-$x)x!/^$x $y/,@a),"@b"+6.2832for@a=<>

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<unistd.h>
#define PI 3.14159265359


using namespace std;
int main()
{

    int W,H;
    while(1){
        cin >> H >> W;

        if(H==0 && W==0) break;
        
        for(int i=0; i<H;i++){
            for(int j=0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;

    }

    return 0;
}



Measured memory_bytes: 3068
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
for j in range(40):
    for i in range(0,n):
        if a[i]%2==0:
            b[i]=b[i]+1
            a[i]=a[i]/2
        else:
            b[i]=b[i]
            a[i]=a[i]
print(sum(b))

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define rep(i, n) for(int i = 0; i < n; i++)
const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
  int N, K;
  cin >> N >> K;
  ll mod = 998244353;
  vi L(K), R(K);
  rep(i, K) {
    cin >> L.at(i) >> R.at(i);
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  vl diff(N - 1, 0);
  diff.at(0) = -1;
  vl way(N, 0);
  way.at(0) = 1;
  rep(i, N - 1) {
    // 現在0からiまでは、たどり着くパターン数がわかっている
    rep(j, K) {
      ll l = L.at(j) + i;
      ll r = R.at(j) + i;
      if(l <= N - 1) {
        diff.at(l - 1) += way.at(i);
        diff.at(l - 1) %= mod;
      }
      if(r <= N - 2) {
        diff.at(r) -= way.at(i);
        diff.at(r) += mod;
        diff.at(r) %= mod;
      }
    }
    way.at(i + 1) = way.at(i) + diff.at(i);
    way.at(i + 1) %= mod;
  }
  cout << way.at(N - 1) << endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int N,Y,k = 0 ;
//int x = 0,y = 0,z = 0;
int main()
{
    cin >> N >> Y;
    Y /= 1000;
    for(int x = 0;x * 10 <= Y;x++){
        for(int y = 0;y * 5 <= Y;y++){
            int z = Y - x * 10 - y * 5;
            if(x + y + z == N && z >= 0){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");


    return 0;
}


Measured memory_bytes: 256
// 枝刈りBFS
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int H, W, K;
vector<string> grid;
vector<vector<int>> d;

void bfs(int sx, int sy)
{
	queue<pair<int, int>> que;
	que.push({sx, sy});
	d[sx][sy] = 0;

	while (!que.empty())
	{
		auto v = que.front();
		que.pop();
		int vx = v.first, vy = v.second;

		for (int i = 0; i < 4; i++)
		{
			for (int j = 1; j <= K; j++)
			{
				int nx = vx + dx[i] * j, ny = vy + dy[i] * j;

				if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
					break;

				if (grid[nx][ny] == '@') // 行き止まり
					break;

				if (d[nx][ny] != -1 && d[nx][ny] <= d[vx][vy]) // 行く意味なし
					break;

				if (d[nx][ny] != -1) // 最短ではない
					continue;

				d[nx][ny] = d[vx][vy] + 1;
				que.push({nx, ny});
			}
		}
	}
}

int main()
{
	fast();

	cin >> H >> W >> K;
	int sx, sy, gx, gy;

	cin >> sx >> sy >> gx >> gy;
	sx--, sy--, gx--, gy--;
	grid = vector<string>(H);
	d = vector<vector<int>>(H, vector<int>(W, -1));

	for (int i = 0; i < H; i++)
	{
		cin >> grid[i];
	}

	bfs(sx, sy);

	cout << d[gx][gy] << "\n";
}


Measured memory_bytes: 11100
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	
	cin >> s;
	while (s.size() > 2) {
		s.erase(s.size() - 1);
		if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size())) {
			cout << s.size() << endl;
			return (0);
		}
	}
	
	cout << 2 << endl;
	
	return (0);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ca = []
cnt = 0
for i in range(len(a)-1):
  if(a[i]<a[i+1]):
    ca.append(cnt)
    cnt = 0
  else:
    cnt += 1
ca.append(0)
ans = max(max(ca), cnt)
print(ans)

Measured memory_bytes: 14252
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)

int main() {
	int N = 0,result=0;
	scanf("%d", &N);
	for (int i = 1; i <= 9; i++) {
		if (N%i == 0 && N / i < 10) {
			result = 1;
		}
	}
	if (result == 1)
		printf("Yes");
	else
		printf("No");
	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int a[3];

int main(){
  REP(i, 3) cin >> a[i];
  sort(a, a + 3);

  REP(i, 3) {
    if(a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  if(a[0] == a[2]) {
    cout << -1 << endl;
    return 0;
  }

  int l = a[1] - a[0], r = a[2] - a[1];
  int ans = 0;
  while((l % 2 == 0) && (r % 2 == 0)) {
    l /= 2;
    r /= 2;
    ans ++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(int argc, char const *argv[])
{
	int a,b,c,m;
	cin >>a>>b>>c;
	m = min(b+c,c+a);
	cout <<min(a+b,m)<< "\n";
	return 0;
}	

Measured memory_bytes: 256
let N = Int(readLine()!)!

var A = [[Int]]()
for _ in stride(from: 0, to: 2, by: 1) {
    let row = readLine()!.split(separator: " ").map { Int($0)! }
    A.append(row)
}

var dp = Array(repeating: Array(repeating: 0, count: N), count: 2)
for j in stride(from: 0, to: N, by: 1) {
    for i in stride(from: 0, to: 2, by: 1) {
        switch (i == 0, j == 0) {
        case (true, true):
            dp[0][0] = A[0][0]
        case (false, true):
            dp[1][0] = dp[0][0] + A[1][0]
        case (true, false):
            dp[0][j] = dp[0][j - 1] + A[0][j]
        case (false, false):
            dp[1][j] = max(dp[0][j], dp[1][j - 1]) + A[1][j]
        }
    }
}

print(dp.last!.last!)


Measured memory_bytes: 8332
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(#x".in", "r", stdin),freopen(#x".out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 200010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
void upd(int &a, int b) { (a += b) %= MOD ; }
void mul(int &a, int b) { a = 1ll * a * b % MOD ; }

int n ;
int a[N], dp[N], pre[N] ;

signed main(){
//	freopen("test.in", "r", stdin) ;
//	freopen("test.out", "w", stdout) ;
	scanf("%d", &n) ;
	rep(i, 1, n) scanf("%d", &a[i]) ;
	clr(dp) ; clr(pre) ;
	dp[1] = 1 ; pre[a[1]] = 1 ;
	rep(i, 2, n) {
		if (a[i] == a[i - 1]) dp[i] = dp[i - 1] ;
		else dp[i] = dp[i - 1] + pre[a[i]] ;
		dp[i] %= MOD ;
		pre[a[i]] = dp[i] ;
	}
	printf("%d\n", dp[n]) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/




Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include <math.h>
#include<vector>
#include<stack>
#include<malloc.h>
#define INF 0x3f3f3f3f
#define maxn 2000006
using namespace std;
struct Node
{
    int a,b;
}s[105];
bool cmp(Node a,Node b)
{
    return a.a<b.a;
}
int main()
{    int n,t,i;
     cin>>n>>t;
     for(i=0;i<n;i++)
     {
         cin>>s[i].a>>s[i].b;
     }
     sort(s,s+n,cmp);
     for(i=0;i<n;i++)
     {
         if(s[i].b<=t)
         {
             cout<<s[i].a<<endl;
             return 0;
         }
     }
     cout<<"TLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int h, w;
int cost[13][13];
int ans;

int main() {
	cin >> h >> w;
	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			cin >> cost[i][j];
		}
	}
	for (int k = 0; k <= 9; ++k) {
		for (int i = 0; i <= 9; ++i) {
			for (int j = 0; j <= 9; ++j) {
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			}
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int a; cin >> a;
			if (a == -1) continue;
			ans += cost[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s = deque(input().replace('\n', ''))
q = int(input())
flag = True
for i in range(q):
    query = list(map(str, input().split()))
    if query[0]=='1':
        if flag: flag = False
        else: flag = True
    else:
        
        if (not flag and query[1]=='1') or flag and query[1]=='2':
            s.append(query[2])
        else:
            s.appendleft(query[2])
s = ''.join(s)
print(s if flag else s[::-1])


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


#define long long long int

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pi;


int main() {
    std::ios_base::sync_with_stdio(false);
    vector<string> v = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    int index = 0;
    for (int i = 0; i < v.size(); ++i) {
        if (v[i] == s){
            index = i + 1;
        }
    }

    cout << v[index % v.size()];
    return 0;
}

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

struct data {
  long long a, b;
  long double lim;
  bool operator<(const data &r) const {
    return lim > r.lim;
  }
};

long long n, t;
vector<data> v;
vector<long long> b;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n >> t;
  for(int i = 0; i < n; ++i) {
    int na, nb;
    cin >> na >> nb;
    if(na == 0)
      b.push_back(nb + 1);
    else
      v.push_back({na, nb, (long double)na / (nb + 1)});
  }
  n = v.size();
  sort(v.begin(), v.end());
  sort(b.begin(), b.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 1; i < b.size(); ++i) b[i] += b[i - 1];
  dp.assign(n + 1, vector<long long>(40, t + 1));
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 40; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(j != 0 && dp[i][j - 1] <= t)
        dp[i + 1][j] = min(
            dp[i + 1][j],
            ((v[i].a + 1) * (dp[i][j - 1] + 1) + v[i].b));
    }
  long long res = 0;
  for(int i = 0; i < 40; ++i)
    if(dp[n][i] <= t)
      res = max(res, (long long)i +
                         (upper_bound(b.begin(), b.end(),
                                      t - dp[n][i]) -
                          b.begin()));
  return res;
}

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

typedef long long ll;
typedef pair<int,int> ii;

const int mx=100;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<ll> L(mx);
	L[0]=2; L[1]=1;
	for (int i=2; i<mx; i++)
		L[i]=L[i-1]+L[i-2];
	int n; cin>>n; cout<<L[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        d: isize,
        p: [(isize, isize); n],
    }

    let ans = p.iter().copied().filter(|(x, y)| *x <= d && *y <= d && *x >= -d && *y >= -d && x * x + y * y <= d * d).count();
    println!("{}", ans);
}


Measured memory_bytes: 7872
#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()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    int ans = 0;
    if(N % 2 == 0){
        ans  = N/2 - 1;
    }
    else ans = N/2;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int X,N;
  cin >> X >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int MIN = INF;
  int ans = 0;
  REP(i,102){
    int flag = 0;
    REP(j,N){
      if(i==A[j]){
        flag=1;
      }
    }
    if(flag==0){
      if(MIN>abs(X-i)){
        MIN=abs(X-i);
        ans=i;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    int L;
	cin >> L;
    double x = (double)L / 3;
    double ans = x*x*x;
    cout << setprecision(8) << ans << endl;
	return 0;
}


Measured memory_bytes: 256