akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_ll a(n);
    cin >> a;
    v_ll sum = a;

    irep(i, n-1) {
        sum[i+1] += sum[i];
    }

    ll ans = 0;

    irep(i, n-1) {
        //cout << ((sum[n-1] - sum[i]) % MOD) << endl;
        //cout << sum[n-1]<< endl; cout << sum[i]<< endl;
        ans += a[i] * ((sum[n-1] - sum[i]) % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 6348
N, K = map(int,input().split())
V = list(map(int,input().split()))

m = min(N,K)
ans = 0
for i in range(m+1):
    for a in range(i+1):
        b = i-a
        if b != 0:
            X = V[:a] + V[-b:]
        else:
            X = V[:a]
        X.sort()
        value = sum(X)
        for e in X[:min((K-i),a+b)]:
            if e < 0:
                value -= e
            else:
                break
        if value > ans:
            ans = value
print(ans)





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

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

int main() {
    int n;
    int a[101000];
    int l[101000] = {0};
    int r[101000] = {0};
    ll ans = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    for (int i = 1; i < n; i++) {
        if (i == 1) {
            l[i] = a[i - 1];
        }
        else {
            l[i] = gcd(l[i - 1], a[i - 1]);
        }
        
        //cout << "l[" << i << "]=" << l[i] << endl;
    }
    
    for (int i = (n - 2); i >= 0; i--) {
        if (i == (n - 2)) {
            r[i] = a[i + 1];
        }
        else {
            r[i] = gcd(r[i + 1], a[i + 1]);
        }
        
        //cout << "r[" << i << "]=" << r[i] << endl;
    }
    
    for (int i = 0; i < n; i++) {
        ans = max(ans, gcd(l[i], r[i]));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
a=int(input())
b=int(input())
if a==1 and b==2:
  print(3)
elif a==2 and b==1:
  print(3)
elif a==3 and b==1:
  print(2)
elif a==3 and b==2:
  print(1)
elif a==1 and b==3:
  print(2)
elif a==2 and b==3:
  print(1)

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

vector<int> route;
#define P 50
#define Q 50
char a[P+2][Q+2];


void search(int place1,int place2){
    a[place1][place2] = '0';
    if(a[place1][place2-1] == '1'){//左
        route.push_back(1);
        search(place1,place2-1);
    }
    else if(a[place1+1][place2] == '1'){//下
        route.push_back(2);
        search(place1+1,place2);
    }
    else if(a[place1][place2+1] == '1'){//右
        route.push_back(3);
        search(place1,place2+1);
    }
    else if(a[place1-1][place2] == '1'){//上
        route.push_back(4);
        search(place1-1,place2);
    }
    else if(a[place1+1][place2-1] == '1'){//左下
        route.push_back(5);
        search(place1+1,place2-1);
    }
    else if(a[place1+1][place2+1] == '1'){//右下
        route.push_back(6);
        search(place1+1,place2+1);
    }
    else if(a[place1-1][place2+1] == '1'){//右上
        route.push_back(7);
        search(place1-1,place2+1);
    }
    else if(a[place1-1][place2-1] == '1'){//左上
        route.push_back(8);
        search(place1-1,place2-1);
    }
    else{
        int bk = route.back();
        route.pop_back();//戻る
        if(bk == 0) return;
        else if(bk == 1)search(place1,place2+1);
        else if(bk == 2)search(place1-1,place2);
        else if(bk == 3)search(place1,place2-1);
        else if(bk == 4)search(place1+1,place2);
        else if(bk == 5)search(place1-1,place2+1);
        else if(bk == 6)search(place1-1,place2-1);
        else if(bk == 7)search(place1+1,place2-1);
        else if(bk == 8)search(place1+1,place2+1);
    }
}

int main(void){
    int ct;
    int x,y;
    while(1){
        ct = 0;
        cin >> y >> x;
        if(x == 0 & y == 0) break;
        for(int i = 0;i < x+2;i++){
            for(int j = 0;j < y+2;j++){
                if(i == 0||j == 0||i == x+1||j == y+1)a[i][j] = '0';
                else cin >> a[i][j];
                
            }
            
        }
        for(int i = 1;i < x+1;i++){
            for(int j = 1;j < y+1;j++){
                if(a[i][j] == '1'){
                    route.push_back(0);
                    search(i,j);
                    ct++;
                }
            }
        }
        cout << ct << endl;
    }
    return 0;
}


Measured memory_bytes: 3492
a,b,c,x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if i * 500 + j * 100 + k * 50 == x
    end
  end
end

puts cnt

Measured memory_bytes: 1788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var wrongAnswer1 = int.Parse(ReadLine());
            var wrongAnswer2 = int.Parse(ReadLine());
            if((wrongAnswer1!=1)&&(wrongAnswer2!=1))
            {
                WriteLine(1);
            }else if ((wrongAnswer1 != 2) && (wrongAnswer2 != 2))
            {
                WriteLine(2);
            }
            else
            {
                WriteLine(3);
            }
            
            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    // bit全探索しながら文字連結していきつつ、+がくるか最後にきたら足し合わせる
    ll sum = 0;
    string num;
    string test = "";
    rep(i, 1<<s.size()-1){
        num = string{s.at(0)};
        // num = string{s.at(0)};
        test = num;
        rep(j,s.size()-1){
            if(i>>j&1==1){
                if(num!="") sum += stoll(num);
                num = string{s.at(j+1)};
                test += "+" + string{s.at(j+1)};
            }else{
                num += string{s.at(j+1)};
                test += string{s.at(j+1)};
            }
            if(j==s.size()-2 && num!=""){
                sum += stoll(num);
                // cout << test << endl;
            }
        }
    }
    if(s.size()==1){
        cout << s << endl;
    }else{
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')



h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

def bfs(sy, sx):
  dist = [[0 for x in range(w)] for y in range(h)]
  dy = [0, 1, 0, -1]
  dx = [1, 0, -1, 0]
  Q = deque()
  Q.append((sy, sx))
  while Q:
    q = Q.popleft()
    y = q[0]
    x = q[1]
    d = dist[y][x]
    for i in range(4):
      ny = y + dy[i]
      nx = x + dx[i]
      if ny < 0 or h <= ny or nx < 0 or w <= nx:
        continue
      #迷路における道が'.'、壁が'#'で表されている場合
      if ny == sy and nx == sx:
        continue
      if maze[ny][nx] == '#':
        continue
      nd = d + 1
      if dist[ny][nx] != 0 and nd >= dist[ny][nx]:
        continue
      dist[ny][nx] = nd
      Q.append((ny, nx))
  return max(max(x) for x in dist)

ans = 0
for y in range(h):
  for x in range(w):
    if maze[y][x] == '.':
      ans = max(ans, bfs(y,x))
print(ans)

Measured memory_bytes: 3316
from collections import defaultdict
N,K,*A=map(int,open(0).read().split())

dic = defaultdict(int)
for a in A:
  dic[a] += 1

dic_values = sorted(list(dic.values()))
ans = 0
for i in range(max(len(dic_values)-K,0)):
  ans += dic_values[i]
print(ans)

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

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

        String s = sc.next();
        String t = sc.next();
        String result = "No";

        for(int i = 0; i < s.length(); i++){
            if(t.equals(s)){
                result = "Yes";
            }
            s = turn(s);
        }

        System.out.println(result);
    }

    static String turn(String s){
        String end = s.substring(s.length() - 1, s.length());
        String tmp = end + s;
        return  tmp.substring(0,tmp.length() - 1);
    }
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T;
    cin >> S >> T;

    int diff = (int)S.size() - (int)T.size();
    int index = -1;
    rep(i, diff + 1) {
        bool flag = true;
        rep(j, T.size()) {
            if (S[i + j] != T[j] && S[i + j] != '?') {
                flag = false;
                break;
            }
        }
        if (flag) index = i;
    }

    if (index == -1) {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        rep(i, index) {
            if (S[i] == '?') cout << 'a';
            else cout << S[i];
        }
        rep(i, T.size()) {
            cout << T[i];
        }
        repd(i, index + (int)T.size(), (int)S.size()) {
            if (S[i] == '?') cout << 'a';
            else cout << S[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout cout
#define debug() if(true)
#else
#define dout if(false) cout
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define vrep(i, v) for(auto &i : v)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n,0);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << ((double)H*W / 2.) << " ";

	if (x*2 == W) {
		if (y * 2 == H) {
			cout << 1 << endl;
			return;
		}
	}
	cout << 0 << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

using ld = long double;

int main() {
    int n; cin >> n;
    vector<ld> x(n), r(n);
    for(int i = 0; i < n; ++i) {
        cin >> x[i] >> r[i];
    }

    auto check = [&] (ld y) {
        ld mini = -1e18, maxi = 1e18;
        for(int i = 0; i < n; ++i) {
            const auto d = sqrt(r[i] * r[i] - y * y);
            mini = max(mini, x[i] - d);
            maxi = min(maxi, x[i] + d);
        }
        return mini <= maxi;
    };
    ld lb = 0, ub = *min_element(begin(r), end(r));
    for(int lp = 0; lp <= 100; ++lp) {
        const auto mid = (lb + ub) / 2;
        (check(mid) ? lb : ub) = mid;
    }
    cout << setprecision(10) << fixed << lb << endl;
}



Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	std::vector<int> a;
	int l;
	for (int i = 0; i < n; i++){
		cin >> l;
		a.push_back(l);
	}

	int count = 0;

	bool loop = true;
	while (loop) {
		for (int i = 0; i < n; i++) {
			if (a.at(i) % 2) {
				loop = false;
				break;
			}
			else {
				a.at(i) = a.at(i) / 2;
			}
		}
		if(loop)
			count++;
	}
	cout << count << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const ll MOD = 1000000007;

const double PI = 3.1415926535897932;
/******define variable start******/
ll a, b, c;
/*******define variable end*******/
ll solve(){
    cin >> a >> b >> c;
    if(max(max(a,b),c) == 7 && min(min(a, b),c) == 5 && a + b + c == 17){
        cout << "YES"<< endl;
    }else{
        cout <<"NO" <<endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            
            // 整数配列の入力
            var pArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long min = long.MaxValue;
            long result = 0;
            for(int i = 0; i < n; i++)
            {
                if(pArray[i] <= min)
                {
                    result++;
                    min = pArray[i];
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 36420
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a);
        b >>= 1;
        if (!b)
            break;
        a = (a*a);
    }
    return result;
}
int main()
{
	IOS;
	lli n, k, c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	lli l[n+1];
	memset(l, 0, sizeof(l));
	lli r[n+1];
	memset(r, 0, sizeof(r));
	
	for(lli i = 0; i<n; i++)
	{
		if(s[i] == 'o')
		{
			l[i+1] = l[i] + 1;
			for(lli j = 0; j<c; j++)
			l[min(n, i+j+2)] = l[i+1];
			i+=c;
		} else
		{
			l[i+1] = l[i];
		}
	}

	for(lli j = n-1; j>=0; j--)
	{
		r[j] = r[j+1];
		if(s[j] == 'o')
		{
			r[j]++;
			for(lli i = 0; i<c; i++)
			{
				r[max(0LL, j-i-1)] = r[j];
			}
			j-=c;
		}
	}

	for(lli i = 0; i<n; i++)
	if(l[i] + r[i+1] < k)
	cout<<i+1<<endl;
	
}



Measured memory_bytes: 5012
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

dx, dy = -dy, dx
x3 = x2 + dx
y3 = y2 + dy

dx, dy = -dy, dx
x4 = x3 + dx
y4 = y3 + dy

print(x3, y3, x4, y4)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String[] a;
        int num = 0, sum = 0, cnt = 0;
        double avg;
        while(sc.hasNext()) {
            a = sc.next().split(",");
            sum += Integer.parseInt(a[0]) * Integer.parseInt(a[1]);
            num += Integer.parseInt(a[1]);
            cnt++;
        }
        avg = (double)num / cnt;
        
        System.out.println(sum);
        System.out.println(Math.round(avg));
    }
}

Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, r;
	int K;
	cin >> s >> K;
	for (char c : s) {
		int t = ('z' - c + 1) % 26;
		if (t <= K) {
			r += 'a';
			K -= t;
		} else {
			r += c;
		}
	}
	r[r.length() - 1] = (r[r.length() - 1] - 'a' + K) % 26 + 'a';
	cout << r << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;

int freq[N], cum[N];

bool tmam(int mid, int i){
    ll ans = freq[mid - 1] / mid + cum[mid];
    return ans >= i;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        freq[x]++;
    }
    vector<int> v;
    for(int i = 1; i <= 3e5; i++){
        if(freq[i]) v.push_back(freq[i]);
    }
    sort(v.begin(), v.end());
    memset(freq, 0, sizeof freq);
    for(int i = 0; i < v.size(); i++){
        int x = v[i];
        freq[x] = freq[x] + x;
    }
    for(int i = 1; i <= 3e5; i++){
        freq[i] += freq[i - 1];
    }
    for(int i = (int) v.size() - 1; i >= 0; i--){
        int x = v[i];
        cum[x]++;
    }
    for(int i = 3e5; i; i--) cum[i] += cum[i + 1];
    // for(int i = 1; i <= n; i++) cout << freq[i] << ' ';
    for(int i = 1; i <= n; i++){
        int low = 1, high = n / i, mid, ans = 0;
        while(high >= low){
            mid = low + high >> 1;
            if(tmam(mid, i)){
                ans = mid;
                low = mid + 1;
            }
            else high = mid - 1;
        }
        cout << ans << '\n';
    }

    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

// G13E_5.cpp

const LL MOD = 1000000007;

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3], LL MOD = MOD) { // a = b * c;
	LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = 0;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
	inc(k, 3) {
		(d[i][j] += b[i][k] * c[k][j]) %= MOD;
	}
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
	
	return;
}

void mat_exp(LL a[3][3], LL b[3][3], LL c, LL MOD = MOD) { // a = b ^ c;
	LL t[60][3][3];
	if(true) {
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 60 - 1) {
			mat_prod(t[i + 1], t[i], t[i], MOD);
		}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, 60) {
		if((c >> i) & 1) {
			mat_prod(a, a, t[i], MOD);
		}
	}
	
	return;
}



LL n, m, x[100002];

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c); }
		mat_exp(d, a, x[i + 1] - x[i] - 1);
		mat_prod(c, d, c);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


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

int main()
{
 int N;
 cin >> N;
 vector<long long> L(86);
 L[0] = 2;
 L[1] = 1;
 for(int i = 2; i <=N; i++)
 {
     L[i] = L[i - 1] + L[i - 2];
 }
 cout << L[N] << endl;
}

Measured memory_bytes: 256
def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]

[a,b,c,k] = getlsi()
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a - (k - a - b))


Measured memory_bytes: 61856
c1 = list( map(int,input().split()))
c2 = list( map(int,input().split()))
c3 = list( map(int,input().split()))

if(     c1[0]-c2[0]==c1[1]-c2[1]
    and c1[1]-c2[1]==c1[2]-c2[2]
    and c2[0]-c3[0]==c2[1]-c3[1]
    and c2[1]-c3[1]==c2[2]-c3[2]
    and c3[0]-c1[0]==c3[1]-c1[1]
    and c3[1]-c1[1]==c3[2]-c1[2]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
/*
* @Author: dnhirapara
* @Date: 2020-04-27 23:12
* @Name: dp_f
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}


//@time comp : O(N^2)
//@space comp : O(N^2)
int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll a, b;
    string s, t;
    cin>>s>>t;
    a = s.size();
    b = t.size();
    ll dp[a+1][b+1] ;
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=a;i++){
        for(ll j=1;j<=b;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = max(dp[i-1][j-1]+1,dp[i][j]);
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    // for(ll i=0;i<=a;i++){
    //     for(ll j=0;j<=b;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    ll col = b, row = a;
    string ans;
    while(row && col){
        if(!(dp[row][col]==dp[row][col-1] || dp[row][col]==dp[row-1][col])){
            ans += s[row-1] ;
            row--;
            col--;
        }else if(dp[row][col]==dp[row][col-1]){
            col--;
        }else{
            row--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    // cout<<dp[a][b]<<endl;
    return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const ll mod=1e9+7;
ll xsum[100005]={0},ysum[100005]={0},x[100005],y[100005];
signed main(){
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++) cin>>x[i];
  for(int i=1;i<=m;i++) cin>>y[i];
  for(int i=1;i<=n;i++){
    xsum[i]=xsum[i-1]+x[i];
    xsum[i]%=mod;
  }
  for(int i=1;i<=m;i++){
    ysum[i]=ysum[i-1]+y[i];
    ysum[i]%=mod;
  }
  ll xs=0,ys=0;
  for(int i=1;i<n;i++){
    ll kx=xsum[n]-xsum[i]+mod*2;
    kx-=((n-i)*x[i])%mod;
    kx%=mod;
    xs+=kx;
    xs%=mod;
  }
  for(int i=1;i<m;i++){
    ll ky=ysum[m]-ysum[i]+mod*2;
    ky-=((m-i)*y[i])%mod;
    ky%=mod;
    ys+=ky;
    ys%=mod;
  }
  cout<<xs*ys%mod<<endl;
}


Measured memory_bytes: 3328
#include <map>
#include <list>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s1,s2;
int main()
{
    fast; 
    cin>>s1>>s2;
    reverse(s1.begin(),s1.end());
    if (s1==s2)
       cout<<"YES"<<endl;
    else
       cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

int main()                  
{
    int n;
    
    scn(n);
    
    int a[n],dp[n];
    
    rep(i,0,n)
    scn(a[i]);
    
    dp[0]=0;
    
    dp[1]=abs(a[1]-a[0]);
    
    rep(i,2,n)
    {
        int v1,v2;
        
        v1=abs(a[i]-a[i-1])+dp[i-1];
        
        v2=abs(a[i]-a[i-2])+dp[i-2];
        
        dp[i]=min(v1,v2);
    }
    
    pri(dp[n-1]);
    
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    // if (a < b)
    // {
    //     swap(a, b);
    //     swap(v, w);
    // }
    ll tmp, tmp_v;

    if (a - b < 0)
    {
        tmp = b - a;
        tmp_v = v - w;
    }
    else
    {
        tmp = a - b;
        tmp_v = v - w;
    }

    if (tmp <= tmp_v * t)
    {
        cout << "YES" << endl;
        return 0;
        // if (tmp % tmp_v == 0)
        // {
        //     cout << "YES" << endl;
        //     return 0;
        // }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3636
s = gets.chomp
n = gets.to_i
lr = 0
op = "+"
s.each_char do |c|
    if c == "+" || c == "*"
        op = c
    else
        if op == "+"
            lr += c.to_i
        else
            lr *= c.to_i
        end
    end
end
ma = eval(s)
if n == lr
    puts "L" if n != ma
    puts "U" if n == ma
else
    puts "I" if n != ma
    puts "M" if n == ma
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool flag = false;
  for(int i = 1; i <= B; i++){
   if(A * i % B == C % B) flag = true;
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
#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     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};


int main()
{
    int t,n,x;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<(n/x)*t<<endl;
    }
    else cout<<((n/x)+1)*t<<endl;
}



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

int main(){
    int a,b,k,c=0,x;
    cin >> a >> b >> k;
    for(int i=max(a,b);i>=0;i--){
        if(a%i==0&&b%i==0){
            c++;
            x=i;
        }
        if(c==k) break;
    }
    cout << x << endl;
 }


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

using namespace std;

int main(){
  int A,N;
  map<int,int> cnt;
  cin  >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    cnt[A]++;
  }
  int ans = 0;
  for(auto & x : cnt){
    //% 2 の代わりにビットマスクで & 1にする
    if(x.second & 1) ans ++;
  }
  cout << ans  << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>
#define HEAP 250

int main(){
  int i, n, key[HEAP];

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    scanf("%d", &key[i]);
  }

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, key[i]);
    if(i > 1) printf("parent key = %d, ", key[i / 2]);
    if(i * 2 <= n) printf("left key = %d, ", key[i * 2]);
    if(i * 2 + 1 <= n) printf("right key = %d, ", key[i * 2 + 1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
L, R = map(int, input().split())
if R - L < 2019:
    ans = float('inf')
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j  % 2019)
    print(ans)
else:
    print(0)

Measured memory_bytes: 2940
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
m = 0
tmp = -2
for i in range(1,n+1):
    m += b[a[i-1]-1]
    if tmp + 1 == a[i-1]:
        m += c[tmp-1]
    tmp = a[i-1]
print(m)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<long,int> >A;
int n,k;
bool used[1<<17];
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int t;long d;cin>>t>>d;
		A.push_back(make_pair(-d,t));
	}
	sort(A.begin(),A.end());
	long ans=0,now=0,cnt=0;
	vector<long>t;
	for(int i=0;i<k;i++)
	{
		now-=A[i].first;
		if(!used[A[i].second])
		{
			used[A[i].second]=1;
			cnt++;
		}
		else
		{
			t.push_back(A[i].first);
		}
	}
	int id=k;
	sort(t.begin(),t.end());
	ans=now+cnt*cnt;
	while(!t.empty()&&id<n)
	{
		if(!used[A[id].second])
		{
			now+=t.back();
			t.pop_back();
			now-=A[id].first;
			used[A[id].second]=1;
			cnt++;
			ans=max(ans,now+cnt*cnt);
		}
		id++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2672
N,M=gets.split.map(&:to_i)
as=Array.new
cs=Array.new
M.times do
  a,b=gets.split.map(&:to_i)
  as << a
  cs << gets.split.map(&:to_i).map{|e|(1<<(e-1))}.inject(:+)
end
dp=Array.new(2**N,Float::INFINITY)
dp[0]=0
for i in 1..M
  dp_next=Array.new(2**N,Float::INFINITY)
  for j in 0...2**N
    a=dp_next[j]
    b=dp[j]
    dp_next[j]= b<a ? b : a
    a=dp_next[j | cs[i-1]]
    b=dp[j]+as[i-1]
    dp_next[j | cs[i-1]]= b<a ? b : a
  end
  dp=dp_next.clone
end
p dp[2**N-1]==Float::INFINITY ? -1 : dp[2**N-1]
    
  

Measured memory_bytes: 16892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n;
  cin>>n;
  cout<<((n*(n-1))/2)<<endl;
  //caricurate
  //output
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			// int[] a = new int[n];
			// int[] b = new int[n];
			HashSet<Integer> listA = new HashSet<Integer>();
			HashSet<Integer> listB = new HashSet<Integer>();
			String ans = "IMPOSSIBLE";
			for (int i = 0; i < m; i++) {
				int a = in.nextInt();
				int b = in.nextInt();
				if (a == 1) {
					listA.add(b);
					if (listB.contains(b)) {
						ans = "POSSIBLE";
						break;
					}
				}
				if (b == n) {
					listB.add(a);
					if (listA.contains(a)) {
						ans = "POSSIBLE";
						break;
					}
				}
			}

			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 58840
using System;

namespace Apple_Pie
{
    class MainClass
    {
        const int needPiece = 2;
        const int getPieceOfApple = 3;

        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            int apple = int.Parse(inputs[0]);
            int piece = int.Parse(inputs[1]);

            int allPiece = (apple * getPieceOfApple) + piece;
            int applePie = allPiece / needPiece;

            Console.WriteLine(applePie);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
/*
vector<int> r(n);
vector<string> v(n, string(m,"*"));
vector<vector<int>>
*/

int main() {
	int n, m,i,j;
	cin >> n;
	string st;
	vector<int> c(n,0);
	vector<string> s(n);

	for (i = 0; i < n; i++) {
		cin >> st;
		for (j = 0; j < i; j++) {
			if (st == s.at(j))break;
		}
		if (i == j) {
			s.at(j) = st;
		}
		if(j<n)c.at(j)++;
	}
	//for (i = 0; i < n; i++)cout << c.at(i) << endl;
	
	cin >> m;
	for (i = 0; i < m; i++) {
		cin >> st;
		for (j = 0; j<n; j++) {
			if (st == s.at(j)) {
				break;
			}
		}
		if(j<n && st == s.at(j))c.at(j)--;
	}
	//for (i = 0; i < n; i++)cout << c.at(i) << endl;
	
	j = 0;
	for (i = 0; i < n; i++) {
		if (c.at(i) > j) {
			j = c.at(i);
		}
	}
	cout << j << endl;
	return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
        import java.util.*;
        import java.io.*;
 
public class Main {
    static long[]memo;
    static int mod = (int)1e9+7;
    static long dp(int sum){
        if (sum<=2)
            return sum==0?1:0;
        if (memo[sum]!=-1)
            return memo[sum];
        long ans=0;
        for (int i =3;i<=sum;i++){
            ans+=dp(sum-i);
            ans%=mod;
        }
        return memo[sum]=ans;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        memo= new long[n+1];
        Arrays.fill(memo,-1);
        pw.println(dp(n));
        pw.flush();
 
    }
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;
 
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }
 
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }
 
    }
 
}

Measured memory_bytes: 34324
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
//#include "windows.h"

#define pb push_back
#define ppb pop_back
#define mmp make_pair
#define nd second
#define st first
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define irt pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

using namespace std; 

string s; 

int w; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cin >> s; 
	cin >> w; 
	
	for (int i = 0; i < s.size(); i += w) cout << s[i]; 
	cout << endl; 
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;
static const int MAX = 1000000;
static const int NIL = -1;

int n;
vector<int> G[MAX];     //頂点数を1000000とする
                        //隣接リスト
int color[MAX];

void dfs( int r, int c ) {
    stack<int> S;
    S.push(r);          //始点rをスタックに追加
    color[r] = c;       //色をいれる
    while ( !S.empty() ) {
        int u = S.top();
        S.pop();        //スタックから頂点uを取り出し訪問
        for ( int i = 0; i < G[u].size(); ++i ) {
            int v = G[u][i];
            //頂点uに隣接する頂点vを探索
            if ( color[v] == NIL ) {
                color[v] = c;
                S.push(v);//id(色)は変わらない
            }
        }
    }
}

void assignColor() {
    int id = 1;             //全てにNIL
    for ( int i = 0; i < n; ++i ) color[i] = NIL;
    for ( int u = 0; u < n; ++u ) {
        if ( color[u] == NIL ) dfs( u , id++ ); //id(色)にかぶりがないように
    }
}

int main() {
    int s, t, m, q;

    scanf("%d %d",&n,&m);

    for ( int i = 0; i < m; ++i ) {
        scanf("%d %d",&s,&t);
        G[s].push_back(t);  // s → tへ辺
        G[t].push_back(s);  // t → sへ辺
    }

    assignColor();

    scanf("%d",&q);

    for ( int i = 0; i < q; ++i ) {
        scanf("%d %d",&s,&t);
        if ( color[s] == color[t] ) {
            puts("yes");
        } else {
            puts("no");
        }
    }

    return 0;
}




Measured memory_bytes: 30128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) break;
        a -= d;
    }
    if (a > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] input = br.readLine().split(" ");
		int[] num = new int[Dice.SURFACE];

		for(int i = 0; i < input.length; i++){
			num[i] = Integer.parseInt(input[i]);
		}

		Dice dice = new Dice(num);
		int q = Integer.parseInt(br.readLine());

		for(int i = 0; i < q; i++){
			input = br.readLine().split(" ");
			int top = Integer.parseInt(input[0]);
			int front = Integer.parseInt(input[1]);
			dice.fixing(top, front);
			sb.append(dice.getNum(Dice.RIGHT) + "\n");
		}

		System.out.print(sb);

	}
}

class Dice{

	static final int SURFACE = 6;
	static final int TOP = 1;
	static final int FRONT = 2;
	static final int RIGHT = 3;
	static final int LEFT = 4;
	static final int REAR = 5;
	static final int BOTTOM = 6;
	private int[] num = new int[SURFACE];

	public Dice(int[] set){

		for(int i = 0; i < SURFACE; i++){
			num[i] = set[i];
		}

	}

	public int getNum(int rabel){

		return num[rabel - 1];

	}

	public int getRabel(int n){

		for(int i = 0; i < SURFACE; i++){

			if(n == num[i]){
				return i + 1;
			}

		}

		return -1;

	}

	public void moveE(){

		int temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;

	}

	public void moveN(){

		int temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;

	}

	public void moveS(){

		int temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;

	}

	public void moveW(){

		int temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;

	}

	public void spinL(){

		int temp = num[1];
		num[1] = num[2];
		num[2] = num[4];
		num[4] = num[3];
		num[3] = temp;

	}

	public void spinR(){

		int temp = num[1];
		num[1] = num[3];
		num[3] = num[4];
		num[4] = num[2];
		num[2] = temp;

	}

	public void fixing(int top, int front){

		switch(getRabel(top)){
			case 2:
				moveN();
				break;
			case 3:
				moveW();
				break;
			case 4:
				moveE();
				break;
			case 5:
				moveS();
				break;
			case 6:
				moveN();
				moveN();
				break;
		}

		switch(getRabel(front)){
			case 3:
				spinL();
				break;
			case 4:
				spinR();
				break;
			case 5:
				spinR();
				spinR();
				break;
		}

	}

}

Measured memory_bytes: 24240