akhauriyash/Code-Regression huggingface dataset:
//https://qiita.com/hkrutknouch/items/910c371e2828787e4292
//https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1028_abc076#c_-_dubious_document_2
//参考にさせて頂いた解説

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    string I,T;
    string NA="UNRESTORABLE";
    cin>>I>>T;
    int L=T.length();
    int Sec=I.length()-L+1;
    vector<string> S;
    for(int i=0;i<Sec;i++){
        string Cut=I.substr(i,L);
        bool ok=true;
        for(int j=0;j<L;j++){
            if(Cut[j]!=T[j]&&Cut[j]!='?'){
                ok=false;
                break;
            }
        }
        if(ok){
            string A=I;
            A.replace(i,L,T);
            S.push_back(A);
        }
    }
    if(S.size()==0){
        cout<<NA<<endl;
        return 0;
    }
    sort(S.begin(),S.end());
    I=S[0];
    rep(i,I.length()){
        if(I[i]=='?')I[i]='a';
    }
    cout<<I<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// 素因数分解
// map -> first: 素数 second: first の数
map<int, int> prime_factor(int n) {
    map<int, int> res;
    for(int i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) { res[n] = 1; }
    return res;
}

int prime[MAX_N];           // i 番目の素数
bool is_prime[MAX_N + 1];   // is_prime[i] が true なら i は素数

// prime と is_prime のテーブルを [0, n] の範囲で作成
// n 以下の素数の数を返す
int sieve(int n) {
    int p = 0;
    for(int i = 0; i <= n; ++i) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i = 1; i <= n; ++i) {
        if(is_prime[i]) {
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

ll N;
vector<ll> prime_v;   // [1, 100] の範囲の素数

signed main()
{
    cin >> N;

    // N! を素因数分解した結果を格納する
    map<int, int> npf;
    for(int i = 2; i <= N; ++i) {
        map<int, int> ret = prime_factor(i);
        for(auto& r : ret) {
            npf[r.first] += r.second;
        }
    }

    // prime_v の作成
    int prime_v_size = sieve(100);
    prime_v.assign(prime_v_size, 0);
    REP(i, prime_v_size) {
        prime_v[i] = prime[i];
    }

    // 75 数は 素因数分解した結果がある特定のパターンになったものである
    ll ans = 0;
    // X^2 * Y^4 * Z^4 のパターン
    for(int x = 0; x < prime_v.size(); ++x) {
        for(int y = 0; y < prime_v.size(); ++y) {
            if(x == y) { continue; }
            for(int z = y + 1; z < prime_v.size(); ++z) {
                if(x == z) { continue; }
                // N! の素因数分解の数がパターンより多いなら、 N! の約数である 75 数を作成可能
                if(npf[prime_v[x]] >= 2 && npf[prime_v[y]] >= 4 && npf[prime_v[z]] >= 4) { ans++; }
            }
        }
    }
    // X^2 * Y^24 のパターン
    // X^4 * Y^14 のパターン
    for(int x = 0; x < prime_v.size(); ++x) {
        for(int y = 0; y < prime_v.size(); ++y) {
            if(x == y) { continue; }
            if(npf[prime_v[x]] >= 2 && npf[prime_v[y]] >= 24) { ans++; }
            if(npf[prime_v[x]] >= 4 && npf[prime_v[y]] >= 14) { ans++; }
        }
    }
    // X^74 のパターン
    for(int x = 0; x < prime_v.size(); ++x) {
        if(npf[prime_v[x]] >= 74) { ans++; }
    }

    printf("%lld\n", ans);
    return 0;
}


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


int main() {
    long long int n,i,count=0;
    string s;
    cin>>n>>s;
    for(i=0;i<s.length();i++)
    {
       count++;
       while((i+1<s.length())&&(s[i+1]==s[i]))
       {
       i++;
       }
    }
    cout<<count;

     

  return 0;
    
}
    


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<ll, int> ms;
    ll st = 0, ans = 0;
    ms[0] = 1;
    
    rep(i, n) {
        if (i == 0) {
            st = a[i];
        }
        else {
            st = st + a[i];
        }
        
        ans += ms[st];
        ms[st]++;
    }
    
    cout << ans << endl;
    return 0;
}


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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

typedef long double ld;

const int oo = 1e18;

string cad;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> cad;

    if(cad[2] == cad[3] && cad[4] == cad[5])cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    rep(i, m) {
        if(a[i] * 4 * m < sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long  ll;
typedef long double ld;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
const ld pi=3.14159265359;
const int maxn=2e5+7;
const int mod=1e9+7;
const ll INF=9223372036854775807;
const int inf=2e9+7; 
/*Almost copy pasted part :)*/
//additional
#define int long long 
//
int a[maxn];


int32_t main(){
	int n;
	int x;
	cin>>n>>x;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ans+=max(0ll,a[i]-x);
		a[i]=min(a[i],x);
	}
	a[0]=0;
	a[n+1]=0;
	for(int i=2;i<=n;i++){
		int p=a[i]+a[i-1];
		int ret=max(0ll,p-x);
		ans+=ret;
		int dec=min(ret,a[i]);
		ret=-dec;
		a[i]-=dec;
		a[i-1]-=ret;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long 
void solve(ll x,ll y,ll z,ll w){
cout<<max(x*w,max(y*w,max(x*z,y*z))); 
}
  
int main() { 
ll x,y,z,w;
cin>>x>>y>>z>>w; 
solve(x,y,z,w);
return 0;
 }

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	string s; cin >> s;
	int l = 0, r = s.length() - 1;
	while (s[l] != 'A')l++;
	while (s[r] != 'Z')r--;
	cout << (r - l + 1) << endl;

	return 0;
}


Measured memory_bytes: 640
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio 		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp	     make_pair
#define inf         0x3f3f3f3f
//#define INF         0x3f3f3f3f3f3f3f3fLL
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi	    pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define see(x)	    cout<<x<<endl;
#define see2(x,y)   cout<<x<<" "<<y<<endl;
#define see3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
//using namespace __gnu_pbds;

//typedef priority_queue<int> maxHeap;
//typedef priority_queue<int,vector<int>,greater<int>()) minHeap;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
//typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

double dp[3001][3001];

double solve(vector<double>& ar,int i,int x){
    if(x==0)
        return 1.0;
    if(i==0)
        return 0.0;
    if(dp[i][x]!=-1)
        return dp[i][x];
    return dp[i][x] = ar[i]*solve(ar,i-1,x-1) + (1-ar[i])*solve(ar,i-1,x);
}

void solution(){
    int n;
    cin >> n;
    memset(dp,-1,sizeof dp);
    vector<double> ar(n+1);
    loop(i,1,n+1)
        cin >> ar[i];
    cout << fixed << setprecision(10) << solve(ar,n,(n+1)/2) << endl;
}

signed main(){
    fastio
    // #ifndef ONLINE_JUDGE
    // 	freopen("input.txt", "r" , stdin);
    // 	freopen("output.txt", "w", stdout);
    // #endif

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
    	//cout<<"Case #"<<i<<": ";
    	solution();
    }
}




Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n%2 != 0) {
    puts("No");
    return 0;
  }
  string ss = s.substr(0,n/2);
  if (ss+ss == s) {
    puts("Yes");
  }
  else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, g, b int
	fmt.Scanf("%d %d %d", &r, &g, &b)
	if (r*100+g*10+b)%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        long pre = 1;
        long pre2 = 2;
        if(N==1) ans = pre;
	for(int i = 2; i<=N; i++) {
	    ans = pre + pre2;
            pre2 = pre;
            pre = ans;
        }
        System.out.println(ans);
    }
}

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

int main() {
  string S;
  cin >> S;  // SUN,MON,TUE,WED,THU,FRI,SAT 
  if (S == "SUN")
    cout << "7" << endl;
  if (S == "MON")
    cout << "6" << endl;  
  if (S == "TUE")
    cout << "5" << endl;
  if (S == "WED")
    cout << "4" << endl;
  if (S == "THU")
    cout << "3" << endl;
  if (S == "FRI")
    cout << "2" << endl;
  if (S == "SAT")
    cout << "1" << endl;
}

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

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto K = s[2];
    auto A = iota(H).map!(_ => readln.chomp.map!(a => a == '#' ? 1 : 0).array).array;

    auto ans = new int[][](H, W);
    int num = 1;

    foreach (i; 0..H) {
        if (A[i].sum == 0) {
            continue;
        }
        bool flag = false;
        foreach (j; 0..W) {
            if (A[i][j] == 1) {
                if (flag) {
                    num += 1;
                } else {
                    flag = true;
                }
            }
            ans[i][j] = num;
        }
        num += 1;
    }

    bool flag = false;
    if (ans.front.sum > 0) {
        flag = true;
    }

    foreach (i; 1..H) {
        if (ans[i].sum == 0) {
            if (flag) {
                ans[i] = ans[i-1].dup;
            }
        } else {
            flag = true;
        }
    }

    flag = false;
    if (ans.back.sum > 0) {
        flag = true;
    }

    foreach_reverse (i; 0..H-1) {
        if (ans[i].sum == 0) {
            if (flag) {
                ans[i] = ans[i+1].dup;
            }
        } else {
            flag = true;
        }
    }

    ans.each!(a => a.map!(to!string).join(" ").writeln);
}




Measured memory_bytes: 7164
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll N;
    cin>>N;
    vll count(N+1,0);
    vi A(N+1);
    vll c2(N+1,0);
    ll total=0;
    for(ll i=1;i<=N;i++){
        c2[i]=i*(i-1)/2;
    }
    for(ll i=1;i<=N;i++){
        cin>>A[i];
        count[A[i]]++;
    }
    for(ll i=1;i<=N;i++){
        total+=c2[count[i]];
    }
    //cout<<total<<endl;
    vll ans(N+1,total);
    for(ll i=1;i<=N;i++){
        ans[i]+=c2[count[A[i]]-1]-c2[count[A[i]]];
    }
    for(ll i=1;i<=N;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 8064
import java.util.Arrays;
import java.util.Scanner;

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

        int[] firstCoordinate = new int[size];
        int[] secondCoordinate = new int[size];
        int[] array = new int[size];

        for (int i = 0; i < size; i++) {
            firstCoordinate[i] = scanner.nextInt();
            secondCoordinate[i] = scanner.nextInt();
            array[i] = i + 1;
        }

        double sum = 0;
        boolean isFinished = false;
        int counter = 0;
        while (!isFinished) {
            counter++;

            for (int h = 0; h < size - 1; h++) {
                double temp = (Math.pow((double) firstCoordinate[array[h] - 1] - (double) firstCoordinate[array[h + 1] - 1], 2))
                        + (Math.pow((double) secondCoordinate[array[h] - 1] - (double) secondCoordinate[array[h + 1] - 1], 2));
                double tempSqrt = Math.sqrt(temp);
                sum += tempSqrt;
            }

            int first = -1;
            for (int i = array.length - 1; i > 0; i--) {
                if (array[i] > array[i - 1]) {
                    first = i - 1;
                    break;
                }
            }
            if (first == -1) {
                isFinished = true;
            }
            int second = first + 1;
            if (first != -1) {
                for (int i = first + 1; i < array.length; i++) {
                    if (array[i] > array[first] && array[i] < array[second]) {
                        second = i;
                    }
                }
                if (second != first) {
                    swap(array, first, second);
                    Arrays.sort(array, first + 1, array.length);
                }
            }
        }

        System.out.println(sum / counter);
    }

    private static void swap(int[] array, int first, int second) {
        int temp = array[first];
        array[first] = array[second];
        array[second] = temp;
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i = 1; i * i <= n; ++i)
        if(n % i == 0)
            v.push_back(i);
    ll mn = n - 1;
    for(ll i: v)
        if(n / i + i < mn)
            mn = n / i + i - 2;
    cout << mn << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace  std;

int main()
{
    for (int i=1;i<=5;++i){
        int t;scanf("%d",&t);
        if (t==0) {
            printf("%d",i);
            return 0;
        }
    }
}

Measured memory_bytes: 3812
N,M = map(int, input().split())
O = []

for i in range(M):
    p,y = map(int, input().split())
    O.append([i+1, p, y])
O.sort(key=lambda x:x[2])
count=[0 for i in range(N)]

ans = []
for o in O:
    count[o[1]-1]+=1
    ans.append([o[0], o[1], count[o[1]-1]])
ans.sort(key=lambda x:x[0])

for v in ans:
    a1 = str(v[1])
    s = (6 - len(a1)) * "0"
    s += a1
    a2 = str(v[2])
    s += (6 - len(a2)) * "0"
    s += a2
    print( s )

Measured memory_bytes: 38832
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
bool AC[maxn]= {false};
int WA[maxn]= {0};
int main()
{
    int n,m,a;
    cin>>n>>m;
    string s;
    int cntAC=0,cntWA=0;
    for(int i=0; i<m; i++)
    {
        cin>>a>>s;
        if(!AC[a-1])
        {
            if(s[0]=='A')
            {
                cntAC++;
                cntWA+=WA[a-1];
                AC[a-1]=true;
            }
            else
            {
                WA[a-1]++;
            }
        }
    }
    cout<<cntAC<<" "<<cntWA<<endl;
}


Measured memory_bytes: 768
// ARC096
// C - Half and Half

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int solve(int a, int b, int c, int x, int y) {
    c = min(a + b, 2 * c);
    a = min(a, c);
    b = min(b, c);
    int z = min(x, y);
    return (x - z) * a + (y - z) * b + z * c;
}

int main() {
    int A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;

    cout << solve(A, B, C, X, Y) << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
status = [True]*(N+2)
for _ in range(M):
    status[int(input())] = False

dp = [0]*(N+2)
dp[0] = 1
for i in range(N):
    for j in [i+1, i+2]:
        if status[j]:
            dp[j] += dp[i]
            dp[j] %= 10**9+7

print(dp[N])


Measured memory_bytes: 45544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int tmp = c;
      	c = b;
      	b = a;
      	a = tmp;
      	System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 23764
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        if (Character.isUpperCase(sc.next().charAt(0))) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef long long ll;

int main(){
  int s; cin>>s;
  const int mod = 1000000007;
  int dp[2010];
  dp[0] = 1;
  dp[1] = dp[2] = 0;
  rep(i,2005) dp[i+3] = (dp[i+2] + dp[i])%mod;
  cout << dp[s] << endl;
}

Measured memory_bytes: 3644
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]
XYH = sorted(XYH, key=lambda x:x[2])
XYH = XYH[::-1]
flag2 = 0

for x in range(101):
    if flag2 == 1:
        break
    for y in range(101):
        flag = 0
        H = XYH[0][2] + abs(x-XYH[0][0]) + abs(y-XYH[0][1])
        for i in range(1,N):
            if max(H - abs(x-XYH[i][0]) - abs(y-XYH[i][1]), 0) != XYH[i][2]:
                flag = 1
        if flag == 0:
            flag2 = 1
            break
    if flag2 == 1:
        break
ans = [x,y,H]
print(*ans)

Measured memory_bytes: 43888
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int ff(int s,int t) {//from s to t
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
int main(){
	int n,m,l;	
	while(cin>>n>>m>>l){
		vvi cost(n,vi(n,inf));
		rep(i,n)cost[i][i]=0;
		while(m--){
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			cost[a][b]=cost[b][a]=c;
		}
		rep(k,n)rep(i,n)rep(j,n)
			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		MF mf(n*2+2);
		int s=n*2,t=s+1;
		rep(i,n){
			int a;
			cin>>a;
			mf.add_edge(s,i,a);
		}
		rep(i,n){
			int a;
			cin>>a;
			mf.add_edge(i+n,t,a);
		}
		rep(i,n)rep(j,n)if(cost[i][j]<l)mf.add_edge(i,j+n,inf);
		cout<<mf.ff(s,t)<<endl;
	}
}

Measured memory_bytes: 1532
#include<stdio.h>
#include<string.h>


int main()
{
    int N;
    int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
    scanf("%d", &N);

    for (int i = 0; i < N; i++)
    {
        char s[4];
        scanf("%s", s);
        if(strcmp(s,"AC")==0){
            C0++;
        }
        else if(strcmp(s,"WA")==0){
            C1++;
        }
        else if(strcmp(s,"TLE")==0){
            C2++;
        }
        else if(strcmp(s,"RE")==0){
            C3++;
        }
    }


    printf("AC x %d\n", C0);
    printf("WA x %d\n", C1);
    printf("TLE x %d\n", C2);
    printf("RE x %d\n", C3);

    return 0;
}


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

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t ans = 0;
    if (a <= b) {
        if (n == 1) ans = (a == b);
        if (n == 2) ans = 1;
        if (n >= 3) ans = (n-2) * (b-a) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
cnt = 0
k = 0
l = 0
r = 0
for i in range(N) : 
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[len(s) - 1] == "A" : 
        k += 1
    elif s[0] == "B" : 
        l += 1
    elif s[len(s) - 1] == "A" : 
        r += 1
rst = cnt
if k == 0 : 
    rst += min(l , r)
elif k == 1 : 
    rst += min(1 , l)  + min(1 , r)  + max(min(l-1, r-1) , 0)
else : 
    rst += k - 1
    rst += min(1 , l)  + min(1 , r)  + max(min(l-1, r-1) , 0)
print(rst)

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

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int x1 = scan.nextInt();
        int y1 = scan.nextInt();
        int x2 = scan.nextInt();
        int y2 = scan.nextInt();
        int x3 = x2;
        int y3 = y2;
        int x4 = 0;
        int y4 = 0;
        
        int xdiff = x2 - x1;
        int ydiff = y2 - y1;
        
            x3 -= ydiff;
            y3 += xdiff;
            x4 = x3 - xdiff;
            y4 = y3 - ydiff;
            
            System.out.println(x3+ " "+y3+" "+x4+" "+y4);
        

    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt(),k=scan.nextInt(),x,s=0,i;
		for(i=0;i<n;i++) {
			x=scan.nextInt();
			if(x*2>(k-x)*2) s+=(k-x)*2;
			else s+=x*2;
		}
		System.out.print(s);
	}
}

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

//Segment Tree for Range Maximum Query
class SegmentTree{
  int n;
  vl node;
public:
  SegmentTree(int n_){
    n=1;
    while(n<n_)n*=2;
    node = vl(2*n-1,-1e9);
  }

  void update(int k, ll v){
    int cur = k + n-1;
    node[cur] = v;
    while(cur>0){
      cur = (cur-1)/2;
      node[cur] = max(node[cur*2+1],node[cur*2+2]);
    }
  }

  //return maximum value in [a,b). ( [l,r) is interval in which k is.)
  ll RMQ(int a,int b,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return -1e9;
    if(a<=l && r<=b)return node[k];
    ll vl = RMQ(a,b,2*k+1,l,(l+r)/2);
    ll vr = RMQ(a,b,2*k+2,(l+r)/2,r);
    return max(vl,vr);
  }
};

int main(){
  ll n,m;
  while(cin >> n >> m, n){
    vl s(n+1,0);
    rep(i,n){
      cin >> s[i+1];
      (s[i+1] += s[i]) %= m;
    }
    
    vector<pll> ord(n);
    rep(i,n){
      ord[i] = pll(s[i+1],i);
    }
    sort(ord.begin(),ord.end());
    
    SegmentTree st(n);
    ll res = 0;
    rep(i,n){
      ll v = ord[i].first, p = ord[i].second;
      res = max(res, v);
      res = max(res, st.RMQ(p+1,n) + m-v);
      st.update(p,v);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 2364
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#h,w = [int(i) for i in readline().split()]
#n,*d = [int(i) for i in read().split()]

n = int(input())
xy = [[int(i) for i in readline().split()] for _ in range(n)]

def get_max_dist_and_index(a,b):
    d = [(a-x)**2 + (b-y)**2 for x,y in xy]
    m = 0
    idx = 0
    for i,di in enumerate(d):
        if m < di:
            idx = i
            m = di
    return m,idx

x0 = y0 = 0
r = 100.0
ratio = 0.99
ans = 10000000
for _ in range(100000):
    m,i = get_max_dist_and_index(x0,y0)
    #print(m,i,x0,y0,r)
    m **= 0.5
    ans = min(ans,m)
    dx,dy = (xy[i][0]-x0),(xy[i][1]-y0)
    x0 += r*dx/m
    y0 += r*dy/m
    r *= ratio
    
    
print(ans)    
    

Measured memory_bytes: 42344
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

import java.util.HashSet;

public class Main {

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

        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int max = 0;
        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            if (h[i + 1] <= h[i]) {
                count++;
                if (count >= max)
                    max = count;
            } else {
                count = 0;
            }

        }
        System.out.println(max);
    }
}

Measured memory_bytes: 51576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 100000 + 5;
typedef struct
{
    ll value;
    ll num;
}node;
node a[N];
bool comp(node x, node y)
{
    return x.value < y.value;
}
int main()
{
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i ++)
        cin >> a[i].value >> a[i].num;
    sort(a, a + n, comp);
    ll ans = 0;
    for(auto i : a)
    {
        if(m == 0)
            break;
        if(i.num > m)
        {
            ans += m * i.value;
            break;
        }
        else
        {
            ans += i.num * i.value;
            m -= i.num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
A, B, K = map(int, input().split())

mini = min(A, B)
divisors = []
for i in range(1, mini + 1):
    if A % i == 0 and B % i == 0:
        divisors.append(i)

divisors = divisors[::-1]
print(divisors[K - 1])


Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  int N = S.length();
  int zero = 0, one = 0;
  rep(i, N){
    if (S[i] == '0') zero++;
    else one++;
  }
  cout << 2 * min(zero, one) << endl;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A == 1){
    A += 13;
  }
  if(B == 1){
    B += 13;
  }
  if(A == B){
    cout << "Draw" << endl;
  }
  else if(A > B){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}
  

Measured memory_bytes: 256
n,w = map(int,input().split())
L = []
for i in range(n):
  L.append(list(map(int,input().split())))
dp = []
for i in range(n+1):
    T = [0]*(w+1)
    dp.append(T)
for i in range(n-1,-1,-1):
    for j in range(w+1):
        if j < L[i][1]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-L[i][1]]+L[i][0])
print(dp[0][w]) 


Measured memory_bytes: 24204
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

int myf(int x,int d){
    if(x%d==0)return x/d;
    else return x/d+1;
}

signed main(){
    int N,H;cin>>N>>H;
    vector<pair<int,int>>A(2*N);
    REP(i,2*N){
        int a;cin>>a;
        if(i%2==0)A[i]=mp(a,0);
        else A[i]=mp(a,1);
    }
    sort(A.rbegin(),A.rend());
    int ans=0;
    int i=0;
    while(H>0){
        if(A[i].second==0){
            ans+=myf(H,A[i].first);
            break;
        }
        else{
            H-=A[i].first;
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=5e5+100,inf=1e18,LOG=23,mod=1e9 + 7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
//#define int ll

int a[maxn], n,dp[maxn], mx;

main()
{
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i];
	}
	nfor(1, i, n)
	{
		if(a[i] >= a[i + 1])
		{
			dp[i] = dp[i + 1] + 1;
		}
		else
		{
			dp[i] = 1;
		}
		mx = max(mx, dp[i]);
	}
	cout << max(0, mx - 1);
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int n, L[210], ans;

int main()
{
	gi(n);
	for (int i = 1; i <= (n << 1); ++i) gi(L[i]);
	sort(L + 1, L + 2 * n + 1);
	for (int i = 1; i <= (n << 1); i += 2) ans += L[i];
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const ll Inf = 1e18;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, e, t;
  cin >> n >> e >> t;
  vector <ll> x(n + 1);
  for (int i = 0; i < n; ++i) cin >> x[i + 1];
  x[0] = 0;
  vector <ll> dp(n + 1, Inf);
  dp[0] = 0;
  ll bestF = Inf; 
  auto relaxF = [&] (int i) {
    bestF = min(bestF, dp[i] - x[i] - (ll)t * i);
  };
  auto get0 = [&] (int i) {
    return dp[i] - x[i] - 2 * x[i + 1]; 
  };
  auto gett = [&] (int i) {
    return dp[i] - x[i] - 2 * x[i + 1] + 2 * x[i + 1];
  };
  relaxF(0);
  multiset <ll> h0, ht;
  ht.insert(gett(0));
  int uk = 0;
  for (int i = 1; i <= n; ++i) {
    while (uk < i && t - 2 * x[i] + 2 * x[uk + 1] < 0) {
      ht.erase(ht.find(gett(uk)));
      h0.insert(get0(uk));
      ++uk;
    }
    dp[i] = bestF + x[i] + (ll)t * i;
    if (!h0.empty()) dp[i] = min(dp[i], *h0.begin() + 3 * x[i]); 
    if (!ht.empty()) dp[i] = min(dp[i], *ht.begin() + 3 * x[i] + t - 2 * x[i]);
    /*for (int j = i + 1; j <= n; ++j) {
      ll extra = max(0LL, t - 2 * x[j] + 2 * x[i + 1]);
      dp[j] = min(dp[j], dp[i] + 3 * x[j] - x[i] - 2 * x[i + 1] + extra);
    }*/
    relaxF(i);
    ht.insert(gett(i));
  }
  cout << dp[n] + e - x[n] << '\n';
}




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

using namespace std;


typedef long long ll ;
const ll mk = 100055;
const ll logn  = 29;
const ll mod = 1e9 + 7; 
#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define UwU              Mikuwu
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define a_Miku           cho_doi_bot_ngu

ll Sum, ans = 0  ; 

ll log10(ll x) {
	if(x == 0) return 0;
	return log10(x / 10) + 1;
}

ll query(ll x, ll y)
{
    if (!y) return 1;
    ll l = query(x, y / 2);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

signed main()
{
    
    cin >> Sum;
    ll r = 1, sub_sum = 0 ; 
    for (ll l = 1; l < 1e7; l++)
    {
        while (sub_sum + log10(r) <= Sum) sub_sum += log10(r), r++;
        if (sub_sum == Sum) ans++;
        sub_sum -= log10(l);
    }   // brute_forces for Miku to dance uwu
    for (ll dig = 8; dig <= Sum; dig++)
    {
        if (Sum % dig == 0)
        {
            ans = (ans  + query(10, dig) - query(10, dig - 1) - Sum / dig + 1 + mod) % mod;   // number of start a sequence
        }
        ll r = Sum % dig;
        if (r == 0) r += dig;
        ll val = r * (dig + 1);
        ll c = 1ll * dig * (dig + 1);
        if (val < Sum) ans = (ans + (Sum - val) / c + ((Sum - val) % c > 0)) % mod;   // still can take those numbers as a sequence
    }
    cout << ans % mod;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 1000000 + 10;

int N;
long long L;
int Trie[MAXN][2], End[MAXN], nTrie;
char S[MAXN];

void InsertTrie(char* S)
{
	int p = 0;
	for (int i = 0; S[i]; i ++)
	{
		if (Trie[p][S[i] - '0'] == -1)
			Trie[p][S[i] - '0'] = nTrie ++;
		p = Trie[p][S[i] - '0'];
	}
	End[p] = 1;
}

long long DFS(int i, int Dep)
{
	if (Trie[i][0] == -1 && Trie[i][1] == -1)
		return 0;
	
	long long ans = 0;

	for (int c = 0; c < 2; c ++)
	{
		if (Trie[i][c] != -1)
			ans ^= DFS(Trie[i][c], Dep + 1);
		else
		{
			long long tmp = L - Dep;
			tmp = (tmp & -tmp);
			ans ^= tmp;
		}
	}
	return ans;
}

int dp[100];

int mex(set <int> v)
{
	for (int x = 0; ; x ++)
		if (v.find(x) == v.end())
			return x;
}

void Work()
{
	/*
	dp[1] = 1;
	for (int i = 2; i < 100; i ++)
	{
		set <int> s;
		int p = 0;
		s.insert(p);
		for (int j = i - 1; j >= 1; j --)
		{
			p ^= dp[j];
			s.insert(p);
		}
		dp[i] = mex(s);

	}
	*/


	scanf("%d%lld", &N, &L);
	
	memset(Trie, -1, sizeof(Trie));
	nTrie = 1;
	for (int i = 0; i < N; i ++)
	{
		scanf("%s", S);
		InsertTrie(S);
	}

	printf(DFS(0, 0) ? "Alice\n" : "Bob\n");
}
 
int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int b = 0;
    string S;
    cin >> N >> S;

    for (int a = 0; a < N/2;a++){
        if(S.at(a) == S.at((N/2)+a)){
            b++;
        }
    }
   
  if(N%2==1){
        cout << "No" <<endl;
  }else if(b == N/2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
s = input()

for i in range(2**len(s)-1):
  f = s[0]
  for j in range(len(s)-1):
    if (i>>j)&1:
      f += "+"
    else:
      f += "-"
    f += s[j+1]
  ans = eval(f)
  
  if ans == 7:
    break

print(f+'=7')
   

Measured memory_bytes: 3060
N = int(input())
clst = list(input())
cnt = 0
k = -1

if 'R' not in clst or 'W' not in clst:
    pass

else:
    rnum = [i for i, c in enumerate(clst) if c == 'R']
    wnum = [j for j, c in enumerate(clst) if c == 'W'][::-1]

    t = min(len(rnum), len(wnum))

    for i in range(1, t+1):
        if rnum[-i] > wnum[-i]:
            cnt += 1
        else:
            break

print(cnt)

Measured memory_bytes: 19992
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
using namespace std;




int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	ll a, ba, bb;
	scanf("%lld %lld.%lld", &a,&ba,&bb);
	
	ll ans = a*ba;
	ans += (a*bb)/100;
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 3688
package main

import (
  "fmt"
  "container/list"
)

type node struct {
  no int
  cost int
}

func main() {
  k := 0
  fmt.Scan(&k)
  
  deque := list.New()
  visit := make([]int, k)
  
  deque.PushBack(node{1, 0})  // push
  
  for deque.Len()>0 {
    n    := deque.Remove(deque.Front()) // shift
    no   := n.(node).no
    cost := n.(node).cost
    //
    if no == 0 {
      fmt.Println(cost + 1)
      break
    }
    //
    visit[no] = 1
    //
    nxt := (no*10) % k
    if visit[nxt]==0 {
      deque.PushFront(node{nxt, cost}) // unshift
    }
    //
    nxt  = (no+1) % k
    if visit[nxt]==0 {
      deque.PushBack(node{nxt, cost+1}) // push
    }
  }
}

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

using namespace std;

int main()
{
    int N;
    array<int, 100000> a;
    array<bool, 100000> b;

    b.fill(false);

    cin >> N;

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

    int x = 1;
    int cnt = 1;

    int nxt;
    while (true)
    {
        nxt = a[x - 1];
        if (nxt == 2) break;

        if (b[nxt - 1]) break;
        b[nxt - 1] = true;

        x = nxt;
        cnt++;
    }

    printf("%d\n", nxt == 2 ? cnt : -1);
    return 0;
}


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

int main() {
    long long int x, k, d;
    scanf("%lld %lld %lld", &x, &k, &d);
    long long int i, y;
    
    y=x/d;
    if (labs(y)>k) {
        printf("%lld\n", labs(x)-d*k);
        return 0;
    } 
    if (x>0) x=x%d; else x=-(labs(x)%d);
    k=k-labs(y);
    if (k%2==0) {
        printf("%ld\n", labs(x));
        return 0;
    } else if (x>0) {
        printf("%ld\n", labs(x-d));
        return 0;
    } else {
        printf("%ld\n", labs(x+d));
    }
    
    
    /*
    for (i=0;i<k;i++) {
        if (labs(x-d)<labs(x+d)) {
            x=x-d;
        } else {
            x=x+d;
        }
    }
    printf("%ld\n", labs(x));
    */
    return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示		
		String n = sc.next();
		char[] a = n.toCharArray();

		for (int i = 0; i < 3; i++) {
			if (a[i] == '1') {
				a[i] = '9';
			} else {
				a[i] = '1';
			}
		}
		System.out.println(String.valueOf(a));
	}
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    string res = "";
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '1') res.push_back('1');
        else if(s[i] == '0') res.push_back('0');
        else if(res.size() > 0) res.erase(res.size()-1);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, h, w;
    cin >> h >> w >> n;
    
    vector<vector<int>> ans(h, vector<int>(w));
    
    int x = 0, y = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        
        for (int j = 0; j < a; j++) {
            ans[x][y] = i + 1;
            if (x % 2 == 0) {
                y++;
                if (y >= w) {
                    y--;
                    x++;
                }
            }
            else {
                y--;
                if (y < 0) {
                    y++;
                    x++;
                }
            }
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            cout << ans[i][j] << " ";
        cout << "\n";
    }
    
#if 0
    int n;
    cin >> n;
    
    vector<int> a(n);
    
    int n4 = 0, n2 = 0, n1 = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 4 == 0) n4++;
        else if (a[i] % 2 == 0) n2++;
        else n1++;
    }
    
    while (n1 >= 2 && n4 > 0) {
        n1--;
        n4--;
    }
    
    if (n2 == n) {
        cout << "Yes\n";
        return 0;
    }
    
    if (n4 == 0 && (n2 > 0 || n1 > 0)) {
        cout << "No\n";
        return 0;
    }
    
    cout << "Yes\n";
#endif
    
    return 0;
}
 


Measured memory_bytes: 384
import numpy as np
import sys

A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
X_rest = 0


for i in range(A + 1):
    X_rest = X - 500 * i
    if X_rest < 0:
        print(count)
        sys.exit()
    elif X_rest == 0:
        count += 1
        continue
    for j in range(B + 1):
        X_rest = X - 500 * i
        X_rest = X_rest - 100 * j
        if X_rest == 0:
            count += 1
            
            continue

        elif X_rest >= 0 and X_rest % 50 == 0 and X_rest / 50 <= C:
            count += 1
         

print(count)

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

int ans = 0;
int n, m;
void dfs(vector<int> flag, vector<vector<int>> &s, vector<int> &p){
    if(flag.size() == n){
        bool memo = true;
        rep(i, m){
            int x = 0;
            for(int j: s[i]){
                x += flag[j];
            }
            if(x % 2 != p[i]){
                memo = false;
                break;
            }
        }
        if(memo) ans++;
        return;
    }
    vector<int> y;
    y = flag;
    flag.push_back(1);
    y.push_back(0);
    dfs(flag, s, p);
    dfs(y, s, p);
    return;
}

int main(){
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    vector<int> p(m);
    rep(i, m){
        cin >> k[i];
        rep(j, k[i]){
            int s0;
            cin >> s0;
            s0--;
            s[i].push_back(s0);
        }
    }
    rep(i, m) cin >> p[i];
    dfs({}, s, p);
    cout << ans << endl;
}

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

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    long x = nx[1];
    auto AS = readln.split.to!(long[]);

    auto min_as = new long[](N);
    min_as[] = long.max;

    auto res = long.max;
    foreach (i; 0..N) {
        long rr = x * i;
        foreach (j; 0..N) {
            min_as[j] = min(min_as[j], AS[(i+j)%N]);
            rr += min_as[j];
        }
        res = min(res, rr);
    }
    writeln(res);
}

Measured memory_bytes: 2796