akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int X, A,B;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> X >> A >> B;
}

int solve(){
    cout << (X-A)%B << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = list(input())

    count1 = 0
    count2 =0
    b ="1"
    w ="0"
    for i in range(len(S)):
        if int(S[i]) != i%2:
            count1 +=1
        if int(S[i]) != (i+1)%2:
            count2 +=1
    print(min(count1,count2))





if __name__ == "__main__":
    main()


Measured memory_bytes: 9816
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long copy = n;
    int digit = 0;
    long long ans1 = 0;
    while(copy != 0){
        ans1 += copy % 10;
        copy = copy / 10;
        digit++;
    }
    ans1 = max(ans1, (n / (long long)pow(10, digit - 1)) + (digit - 1) * 9 - 1);
    cout << ans1 << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

def factorization(n):
  a = 1
  temp = n
  for i in range(2, int(math.sqrt(n))+1):
    if temp%i == 0:
      cnt = 1
      while temp%i==0:
        cnt += 1
        temp //= i
      a *= cnt
  if temp != 1:
    a *= 2
  return a

if N <= 4*(10**5):
  ans = 0
  for i in range(1, N):
    ans += factorization(i)
elif 4*(10**5) < N <= 6*(10**5):
  ans = 5221424
  for i in range(4*(10**5), N):
    ans += factorization(i)
elif 6*(10**5) < N <= 8*(10**5):
  ans = 8075420
  for i in range(6*(10**5), N):
    ans += factorization(i)
elif 8*(10**5) < N <= 9*(10**5):
  ans = 10997400
  for i in range(8*(10**5), N):
    ans += factorization(i)
else:
  ans = 12478098
  for i in range(9*(10**5), N):
    ans += factorization(i)
print(ans)

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int h, a;
    cin >> h >> a;
    cout << (int)ceil((double)h / a) << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int rec(std::string &S, int k = 0, bool tight = true, int last = -1) {
  if ( k == sz(S) ) return 1;
  int x = S[k] - '0';
  int r = tight ? x : 9;
  int res = 0;
  if ( last != -1 ) {
    for (int i = 0; i <= r; i++) {
      if ( std::abs(last-i) <= 1 ) res += rec(S, k + 1, tight && i == r, i);
    }
  }
  else {
    for (int i = 0; i <= r; i++) {
      if ( i == 0 ) res += rec(S, k + 1, tight && i == r, -1);
      else res += rec(S, k + 1, tight && i == r, i);
    }
  }
  return res;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll K; std::cin >> K;

  ll l = 0;
  ll r = 1e10;
  while ( r - l > 1 ) {
    ll mid = ( l + r ) /2;
    std::string s = std::to_string(mid);
    if ( rec(s) - 1  < K ) {
      l = mid;
    }
    else r = mid;
  }
  std::cout << r << std::endl;
  return 0;
}



Measured memory_bytes: 256
z = []
for i in range(5):
    z.append(int(input()))

k = int(input())

ans = 0
for i in z:
    for j in z:
        if i >= j:
            continue
        if j - i > k:
            ans += 1

if ans > 0:
    print(':(')
else:
    print('Yay!')

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

using namespace std;

int main()
{
  int h,w,counth=0,countw=0;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      cin>>a.at(i).at(j);
    //  cout<<a.at(i).at(j);
    }
    //cout<<endl;
  }
  
  for(int i=0;i<h;i++)
  {
    int j;
    for(j=0;j<w;j++)
    {
      if(a.at(i).at(j)=='#')
        break;
    }
    if(j==w)
    {
      counth++;
      for(int k=i;k>0;k--)
      {
        for(int l=0;l<w;l++)
        {
          a.at(k).at(l)=a.at(k-1).at(l);
        }
      }
    }
  }
  
  for(int i=0;i<w;i++)
  {
    int j;
    for(j=0;j<h;j++)
    {
      if(a.at(j).at(i)=='#')
        break;
    }
    if(j==h)
    {
      countw++;
      for(int k=i;k>0;k--)
      {
        for(int l=0;l<h;l++)
        {
          a.at(l).at(k)=a.at(l).at(k-1);
        }
      }
    }
  }
  for(int i=counth;i<h;i++)
  {
    for(int j=countw;j<w;j++)
    {
      cout<<a.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, X = map(int, input().split())
CAS = [list(map(int, input().split())) for _ in range(N)]

bit = 2 << 12

ANS = 10 ** 10
ok = False
for i in range(bit):
    USE = [False] * N

    for j in range(N):
        USE[j] = i & 1
        i >>= 1

    m = 0
    POINTS = [0] * M
    for j in range(N):
        if not USE[j]:
            continue

        m += CAS[j][0]

        for k in range(M):
            POINTS[k] += CAS[j][k + 1]

    P = [X <= p for p in POINTS]

    if all(P):
        ok = True
        ANS = min(ANS, m)


if not ok:
    print("-1")
else:
    print(ANS)


Measured memory_bytes: 9244
#include <iostream>
using namespace std ;
using ll = long long ;

int main(){
	ll n,x ;
	cin >> n >> x ;
	ll pre ;
	cin >> pre ;
	ll ans = 0 ;
	for(int i=1;i<n;i++){
		int a ; cin >> a ;
		if(a+pre>x){
			if(pre>x){
				ans += a+pre-x ;
				pre = 0 ;
			}else{
				ans += a+pre-x ;
				pre = x-pre ;
			}
		}else{
			pre = a ;
		}
	}
	cout << ans << endl ;
}


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

bool isOK(int y,int x){
    if(0<=y&&y<h&&0<=x&&x<w) return true;
    return false;
}

int main(){
    cin>>h>>w;
    int maze[h][w];
    int reached[h][w];
    memset(reached,-1,sizeof(reached));
    int wallctr=0;
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                maze[i][j]=1;
            }
            else{
                maze[i][j]=0;
                ++wallctr;
            }
        }
    }
    queue<P> Q;
    Q.push(make_pair(0,0));
    reached[0][0]=0;

    while(!Q.empty()){
        P p=Q.front();
        Q.pop();
        rep(i,4){
            if(isOK(p.first+dy[i],p.second+dx[i])&&reached[p.first+dy[i]][p.second+dx[i]]==-1&&maze[p.first+dy[i]][p.second+dx[i]]){
                reached[p.first+dy[i]][p.second+dx[i]]=reached[p.first][p.second]+1;
                Q.push(make_pair(p.first+dy[i],p.second+dx[i]));
            }
        }
    }
    cout<<(reached[h-1][w-1]==-1?-1:h*w-wallctr-reached[h-1][w-1]-1)<<endl;
}





Measured memory_bytes: 256
n, x = gets.strip.split.map(&:to_i)

@burgers = [1]
@meats = [1]

n.times do |i|
  @burgers.push(@burgers.last*2 + 3)
  @meats.push(@meats.last*2+1)
end

def bite_meat(level, bites)
  return 0 if bites == 0
  return 1 if level == 0
  if bites >= @burgers[level-1]+2
    @meats[level-1] + 1 + bite_meat(level-1, bites-@burgers[level-1]-2)
  else
    bite_meat(level-1, bites-1)
  end
end

p bite_meat(n, x)


Measured memory_bytes: 1788
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]
UF = UnionFind(n)
ans = [n * (n - 1) // 2]
for a, b in edges[1:][::-1]:
    a -= 1
    b -= 1
    if UF.same(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - UF.size(a) * UF.size(b))
    UF.union(a, b)
print(*ans[::-1], sep = "\n")


Measured memory_bytes: 35576
#include<iostream>
#include<stdio.h>
using namespace std; 

int main(){
    int n;
    cin >> n;
    int a,max=-1000001,min=1000001;
    long long int sum=0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a>max)max = a;
        if(a<min)min = a;
        sum += a;
    }
    printf("%d %d %lld\n",min,max,sum);
}


Measured memory_bytes: 3224
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  a.sort((a,b)=>b-a);
  var ans = 0;
  for(var i = 0; i < n; i++)ans += i % 2 ? -a[i] : a[i];
  return ans;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if (D >= (X + K - 1) / K) {
        ll a = X / D;
        K -= a;
        if (K % 2 == 0) {
            cout << X - D * a << '\n';
        } else {
            cout << abs(X - D * a - D) << '\n';
        }
    } else {
        cout << X - K * D << '\n';
    }
}

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n;
int a[N], cnt[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		ans += 1ll * cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 1; i <= n; i++) {
		int tmp = cnt[a[i]];
		ll t = ans;
		t -= (1ll * tmp*(tmp - 1) / 2);
		tmp--;
		t += 1ll * tmp*(tmp - 1) / 2;
		printf("%lld\n", t);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

void chmax(int* a, int b){
  if(*a < b){
    *a = b;
  }
}

int main(){
  int n;
  std::cin >> n;

  vector<vector<pair<int, int> > > An(n, vector<pair<int,int> >());

  for(int i=0; i<n; i++){
    int ai;
    cin >> ai;
    vector<pair<int,int> > temp;
    for(int j=0; j<ai; j++){
      int x, y;
      cin >> x >> y;
      temp.push_back( make_pair( x-1, y ) );
    }
    An[i] = temp;
  }

  int ans = 0;
  for(int i=0; i<pow(2, n); i++){
    std::bitset<15> bits(i);

    bool outflag = false;
    for(int j=0; j<n; j++){
      if( bits[j] ){
        // 正直者と仮定した人の言ってることが正しいかをチェックする
        for(int k=0; k<An[j].size(); k++){
          if( bits[An[j][k].first] != An[j][k].second ){
            outflag = true;
          }
        }
      }
    }
    if( !outflag ){
      chmax( &ans, bits.count() );
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}

void chmin(int &a, int &b){if (a>b){a = b; return;}return;}
void chmax(int &a, int &b){if (a<b){a = b; return;}return;}


const ll MOD = 1000000007;
const ll INF = 9999999999;

struct playlist{
  string title;
  int time;
};

int main() {
  int n; cin >>n;
  vector<string> title(n);
  vector<int> time(n);
  for (int i=0; i<n; i++) cin >>title.at(i) >>time.at(i);
  string x; cin >>x;

  int ans = 0;
  bool ok = false;
  for (int i=0; i<n; i++){
    if (ok){
      ans += time.at(i);
      continue;
    }
    if (title.at(i) == x) ok = true;
  }

  cout <<ans <<endl;
}

Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 998244353
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/

int dp[3005][3005];
void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    rep(i, a, c+1){
        rep(j, b, d+1){
            dp[i][j] -= (dp[i-1][j-1]*(i-1)*(j-1))%mod;
            if(dp[i][j] < 0)dp[i][j] += mod;
            dp[i+1][j]  += (dp[i][j]*j)%mod;
            if(dp[i+1][j] >= mod)dp[i+1][j] -= mod;
            dp[i][j+1]  += (dp[i][j]*i)%mod;
            if(dp[i][j+1] >= mod)dp[i][j+1] -= mod;
        }
    }
    cout << dp[c][d];
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

int main() {
    int n, a, b, wa, ans = 100;
    cin >>  n;
    bool finished = false;
    
    for(int i=1; i < n; i++) {
        wa = 0;
        a = i;
        b = n - a;
        while(true) {
            wa += a%10 + b%10;
            a /= 10;
            b /= 10;
            if(a == 0 && b == 0) break;
        }
        if(wa < ans) {
            ans = wa;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);
ll lcm(ll m, ll n);

int main(void) {

	int ans = 0;
	int n;
	cin >> n;

	int a = n / 2;
	int b = a;
	if (n % 2 != 0) b = a + 1;
	ans = a * b;

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  
#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#define inf 1000000000

using namespace std;

int n, s, t;
int q[105];
int G[105][105];
int dist[105][105];

double mat[105][105];

void WarshallFloyd()
{
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			dist[i][j] = G[i][j];
		}
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
}

void swap(int i, int j)
{
	for(int k = 1; k <= n+1; k++){
		double t = mat[i][k];
		mat[i][k] = mat[j][k];
		mat[j][k] = t;
	}
}

int main(void)
{
	while(1){
		cin >> n >> s >> t;
		if(n == 0 && s == 0 && t == 0) break;
		
		for(int i = 1; i <= n; i++) cin >> q[i];
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				cin >> G[i][j];
				if(G[i][j] == 0 && i != j) G[i][j] = inf;
			}
		}
		WarshallFloyd();
		
		if(dist[s][t] >= inf){
			cout << "impossible" << endl;
			continue;
		}
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n+1; j++){
				mat[i][j] = 0;
			}
		}
		for(int i = 1; i <= n; i++){
			if(dist[t][i] >= inf || i == t){
				mat[i][i] = 1;
				continue;
			}
			if(q[i]){
				int cnt = 0, sum = 0;
				for(int j = 1; j <= n; j++){
					if(G[i][j] < inf && G[i][j] + dist[j][t] == dist[i][t]) cnt++, sum += G[i][j];
				}
				mat[i][i] = cnt;
				for(int j = 1; j <= n; j++){
					if(G[i][j] < inf && G[i][j] + dist[j][t] == dist[i][t]) mat[i][j] -= 1;
				}
				mat[i][n+1] = sum;
			}else{
				int cnt = 0, sum = 0;
				for(int j = 1; j <= n; j++){
					if(G[i][j] < inf) cnt++, sum += G[i][j];
				}
				mat[i][i] = cnt;
				for(int j = 1; j <= n; j++){
					if(G[i][j] < inf) mat[i][j] -= 1;
				}
				mat[i][n+1] = sum;
			}
		}
		
		for(int i = 1; i <= n; i++){
			double max_val = 0; int max_j;
			for(int j = i; j <= n; j++){
				if(fabs(mat[j][i]) > max_val){
					max_val = fabs(mat[j][i]);
					max_j = j;
				}
			}
			swap(i, max_j);
			
			double div = mat[i][i];
			for(int j = 1; j <= n+1; j++){
				mat[i][j] /= div;
			}
			for(int j = 1; j <= n; j++){
				double coe = mat[j][i];
				if(i == j) continue;
				for(int k = 1; k <= n+1; k++){
					mat[j][k] -= coe * mat[i][k];
				}
			}
		}
		
		printf("%.11f\n", mat[s][n+1]);
	}
	
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N], B[N], C[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    int *a, *c;
    ll ans = 0;
    rep(i, N) {
        a = lower_bound(A,A+N,B[i]);
        c = upper_bound(C,C+N,B[i]);
        //while(*c == *(c+1)) c = c+1;
        //cout << *c << endl;
        //dump(a-A);
        //dump(N+(C - c));
        ans += (a - A) * (N+(C - (c)));
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
bool check(string s){
	int n=s.size();
	int i=0,j=n-1;
	while(i<j){
		if(s[i]!=s[j])return 0;
		i++;j--;
	}
	return 1;
}
int32_t main(){
 	fastIO;
 	string s;cin>>s;
 	int n=s.size();
 	string t1="",t2="";
 	for(int i=0;i<(n-1)/2;i++)t1+=s[i];
 	for(int i=(n+3)/2-1;i<n;i++)t2+=s[i];
 	if(check(s)&&check(t1)&&check(t2))cout<<"Yes"<<endl;
 	else cout<<"No"<<endl;
} 	

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	function<T(T,T)>calcfn,lazycalcfn;
	function<T(T,T,int,int)>updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		function<T(T,T)>calcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T,int,int)>updatefn_=[](T a,T b,int l,int r){return a+b*(r-l);},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],l,r);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
int N,Q;
main()
{
	scanf("%d%d",&N,&Q);
	lazysegtree<long>P(N,0,[](long a,long b){return a+b;},
	[](long a,long b){return a+b;},
	[](long a,long b,int l,int r){return a+b*(r-l);});
	for(;Q--;)
	{
		int q,s,t;scanf("%d%d%d",&q,&s,&t);
		if(q)
		{
			printf("%ld\n",P.query(s-1,t));
		}
		else
		{
			int x;scanf("%d",&x);
			P.update(s-1,t,x);
		}
	}
}



Measured memory_bytes: 6604
def isalpha(c)
  c.to_i.to_s != c
end

def search(x, y, w, h, mat, values)
  q = []
  q << [x, y]
  until q.empty?
    px, py = q.shift
    [[0, 1], [1, 0]].each do |mx, my|
      x = px + mx; y = py + my
      if x < w && y < h && mat[y][x]
        if (old = values[y][x]) < (now = (values[py][px].to_s + mat[y][x]).to_i)
          values[y][x] = now
          q << [x, y] if old == 0
        end
      end
    end
  end
  values
end

def solve(w, h, mat)
  values = h.times.map{ [0] * w }
  h.times do |y|
    w.times do |x|
      if mat[y][x]
        values[y][x] = mat[y][x].to_i if mat[y][x].to_i > values[y][x]
        values = search(x, y, w, h, mat, values)
      end
    end
  end
  values.flatten.max
end


while l = gets
  w, h = l.split.map(&:to_i)
  break if w == 0 && h == 0
  mat = h.times.map { gets.chomp }
  mat.map!{ |m| m.split('').map{ |c| isalpha(c) ? false : c } }
  puts solve(w, h, mat)
end

Measured memory_bytes: 8984
n,k=map(int, input().split())

import itertools
d_list=[]
a_list=[]
trick_list=[]
trick=0
sunu_list=[i for i in range(1,n+1)]

for i in range(0,k):
  d=int(input())
  d_list.append(d)
  a = list(map(int, input().split()))
  a_list.append(a)

for sunu in a_list:
  trick_list=list(set(sunu_list)-set(sunu))
  sunu_list=trick_list


print(len(sunu_list))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main() {
     int n,X;
     cin >> n >> X;
     vector<int> x(n);
     rep(i,n) cin >> x[i];
     int a  = abs(X-x[0]);
     rep(i,n-1){
         a=  gcd(a,abs(x[i+1]-x[i]));
     }
     cout << a<<endl;
}

Measured memory_bytes: 3736
package main

import (
  "fmt"
)

// argument type must be []rune, not string.
func substr(rs []rune, l, r int) string {
  if l < 0 {l = 0}
  if r > len(rs) {r = len(rs)}
  if l >= r {return ""}
  return string(rs[l:r])
}

func main() {
  var s string 
  fmt.Scan(&s)
  res := []rune(s)
  n := len(res)
  for l := n - 2; l > -1; l -= 2 {
    if substr(res, 0, l/2) == substr(res, l/2, l) {
      fmt.Println(l)
      return
    }
  }
}

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

int main(){
  int a,b;
  double h,m;
  cin >> a >> b >> h >> m;
  h = h*30.0 + m/2.0;
  m *= 6.0;
  double d = abs(h-m);
  double c = min(360.0 - d,d);
  c = c*M_PI/180.0;
  double ans;
  ans = a*a + b*b - 2*a*b*cos(c);
  cout << fixed << setprecision(24) << sqrt(ans) << endl;
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


int main2() {
  int N = nextInt();
  vector<int> b(N);
  REP(i, N) {
    int a = nextInt() - 1;
    b[i] = i == a ? 1 : 0;
  }
  vector<int> lens;
  int len = 0;
  REP(i, N) {
    if (b[i]) {
      len++;
    } else {
      if (len > 0) lens.push_back(len);
      len = 0;
    }
  }
  if (len > 0) lens.push_back(len);

  int ans = 0;
  for (int len : lens) {
    ans += (len + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;

struct UnionFind{
    vector<int> par,sizes;
    UnionFind(int n):par(n+1),sizes(n+1,1){
        rep2(i,1,n)par[i]=i;
    }
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return ;
        if(sizes[x]<sizes[y]){
            swap(x,y);
        }
        par[y]=x;
        sizes[x]+=sizes[y];
    }
    bool same(int x,int y) {return (find(x)==find(y));}
    int size(int x) {return sizes[find(x)];}
};

main(){
    int n=in(),k=in(),l=in();
    UnionFind uf1(n),uf2(n);
    rep(i,k){
        int a,b;cin>>a>>b;
        uf1.unite(a,b);
    }
    rep(i,l){
        int a,b;cin>>a>>b;
        uf2.unite(a,b);
    }
    map<pii,int> mp;
    rep2(i,1,n){
        mp[{uf1.find(i),uf2.find(i)}]++;
    }
    rep2(i,1,n){
        cout<<mp[{uf1.find(i),uf2.find(i)}]<<" ";
    }
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

using mint = ModInt<MOD>;
int main() {
	int n, k; cin >> n >> k;
	mint cnt[k + 1];
	for(int g = k; g >= 1; --g) {
		mint x = k / g;
		cnt[g] = x.pow(n);
	}
	
	mint ans = 0;
	mint ccnt[k + 1];
	for(int i = k; i >= 1; --i) {
		mint tmp = cnt[i];
		for(int j = 2; i * j <= k; ++j) {
			tmp -= ccnt[i * j];
		}
		ccnt[i] = tmp;
		ans += tmp * i;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5176
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, T = nl()
min_c = 10000
for i in range(N):
    c, t = nl()
    if t <= T:
        if c < min_c:
            min_c = c
if min_c == 10000:
    print('TLE')
else:
    print(min_c)


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


struct UnionFind{
    vector<long long> par;
    UnionFind(long long N) : par(N){
        for(long long i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    long long root(long long x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(long long x, long long y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    long long n;
    cin >> n;

    vector<P> A(n);
    for(long long i = 0; i < n; i++){
        cin >> A[i].first >> A[i].second;
    }

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    sort(A.rbegin(), A.rend());



    set<P> st;
    for(long long i = 0; i < n; i++){
        for(long long j = i + 1; j < n; j++){
            st.insert({A[i].first - A[j].first, A[i].second - A[j].second});
        }
    }


    long long ans = 1e9;
    for(auto x : st){
        long long a = x.first;
        long long b = x.second;

        UnionFind uf(n);
        for(long long i = 0; i < n; i++){
            for(long long j = i + 1; j < n; j++){
                long long dx = A[i].first - A[j].first;
                long long dy = A[i].second - A[j].second;
                if(dx == a and dy == b){
                    uf.unite(i, j);
                }
            }
        }

        set<long long> st;
        for(long long i = 0; i < n; i++){
            st.insert(uf.root(i));
        }
        ans = min(ans, (long long)st.size());
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int gcd(int x,int y){
	if (!y) return x;
	return gcd(y,x%y); 
}
int lcm(int x,int y){
	return x*(y/gcd(x,y));
}
int main(){
	vector<int> v;
	int n,x;
	cin >> n;
	for (int i=1;i<=n;++i) cin >> x, v.push_back(x);
	for (int i=0;i<n;++i) {
		v[i+1]=lcm(v[i],v[i+1]); 
	}
	cout << v[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod =1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int n,c;
    cin>>n>>s;
    ll ans=1;
    vector<int> a(26,1);
    for(int i=0;i<n;i++){
        c=(int)(s[i]-'a');
        a[c]++;
    }
    for(int i=0;i<26;i++){
        ans=ans*a[i]%mod;
    }
    cout<<ans-1;
}

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

int main() {
  char cl;
  cin >> cl;
  char ans = 'A';
  if ( cl == 'A' ) { ans = 'T'; }
  if ( cl == 'G' ) { ans = 'C'; }
  if ( cl == 'C' ) { ans = 'G'; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]
mod = sum(XY[0])%2
for x, y in XY:
    if mod != (x+y)%2:
        print(-1)
        exit()

m = 33-mod
print(m)
D = [2**i for i in range(31, -1, -1)]
if mod == 0:
    D.append(1)

print(" ".join(map(str, D)))
for x, y in XY:
    w = " "
    for d in D:
        if x-y >= 0 and x+y >= 0:
            w += "R"
            x -= d
        elif x-y < 0 and x+y >= 0:
            w += "U"
            y -= d
        elif x-y >= 0 and x+y < 0:
            w += "D"
            y += d
        else:
            w += "L"
            x += d
    print(w)



Measured memory_bytes: 3316
using System;
namespace ABC173.Problems
{
    class C
    {
        static void Main()
        {
            string[] ss = Console.ReadLine().Split(' ');
            int h = int.Parse(ss[0]);
            int w = int.Parse(ss[1]);
            int k = int.Parse(ss[2]);
            char[][] field = new char[h][];
            for (int i = 0; i < h; i++)
            {
                field[i] = Console.ReadLine().ToCharArray();
            }
            int res = 0;
            for (int i = 0; i < 1 << h; i++) {
                for (int j = 0; j < 1 << w; j++) {
                    int cnt = 0;
                    for (int y = 0; y < h; y++) {
                        if ((i & (1 << y)) == 0) continue;
                        for (int x = 0; x < w; x++) {
                            if ((j & (1 << x)) == 0) continue;
                            if (field[y][x] == '#') cnt++;
                        }
                    }
                    if (cnt == k) res++;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27540
a = int(input())
b = [a]
d = 1
while True:
    c = b[len(b)-1]
    d += 1
    if c % 2 == 0:
        c = c // 2
    else:
        c = c * 3 + 1
    if c not in b:
        b.append(c)
    else:
        print(d)
        exit()


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

int main() {
    string s; cin >> s;
    int res = 0;
    stack<char> st;
    for (int i = 0; i < s.size(); ++i) {
        if (st.empty() || st.top() == s[i]) st.push(s[i]);
        else {
            res += 2; // ペアを足す
            st.pop();
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

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();
		if (a < b) {
			if (b < c) {
				System.out.printf("%d %d %d\n", a, b, c);
			} else if (a < c) {
				System.out.printf("%d %d %d\n", a, c, b);
			} else {
				System.out.printf("%d %d %d\n", c, a, b);
			}
		} else {
			if (a < c) {
				System.out.printf("%d %d %d\n", b, a, c);
			} else if (b < c) {
				System.out.printf("%d %d %d\n", b, c, a);
			} else {
				System.out.printf("%d %d %d\n", c, b, a);
			}
		}
	}
}



Measured memory_bytes: 26516
#include <iostream>
#include <vector>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i,n) FOR(i, 0, n)

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> pixel(H, vector<char>(W));

	rep(i, H) {
		rep(j, W) {
			cin >> pixel.at(i).at(j);
		}
	}

	int k = 0;
	while (k < W + 2) {
		cout << "#";
		k++;
	}
	cout << endl;

	FOR(i, 0, H) {
		cout << "#";
		FOR(j, 0, W) {
			cout << pixel.at(i).at(j);
		}
		cout << "#" << endl;
	}

	int l = 0;
	while (l < W + 2) {
		cout << "#";
		l++;
	}
	cout << endl;

	return 0;

}

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

using namespace std;
int A[100];

int N;
string in;
int V[100], C[100];

int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i];
  }

  for(int i = 0; i< N; i++) {
    A[i] = V[i] - C[i];
  }
int c = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] > 0) c += A[i];
  }
  cout << c;



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,a,m=1000000000,t,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		t=0;
		while(a%2==0){
			a/=2;
			t++;
		}
		if(m>t)m=t;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int a,b,c,d,e,k;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    if(e-a>k) printf(":(");
    else printf("Yay!");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if((a+b) % 2 == 0) {
			System.out.println((a+b)/2);
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}

}

Measured memory_bytes: 23764
use proconio::*;

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    let mut ans = [0; 10001];

    for x in 1..100 {
        for y in x..100 {
            for z in y..100 {
                let t = x * x + y * y + z * z + x * y + y * z + x * z;
                if t <= n {
                    ans[t] += if x == y && y == z {
                        1
                    } else if x == y || y == z || x == z {
                        3
                    } else {
                        6
                    };
                }
            }
        }
    }

    for a in &ans[1..=n] {
        println!("{}", a);
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<vector<int> > mat(10, vector<int>(10, 0));
  string num;

  int b,e;

  for(int i = 0; i < N; i++){
    // 処理
    num = to_string(i+1);
    b = num[0] - '0';
    e = num[num.size()-1] - '0';
    mat.at(b).at(e) += 1;
  }

  int ans = 0;
  for(int i = 0; i<10;i++){
    for(int j = 0;j<10;j++){
      ans += mat.at(i).at(j) * mat.at(j).at(i); 
    }
  }
  cout << ans << endl;

}




Measured memory_bytes: 256
D = gets.to_i
c = gets.split.map(&:to_i)
s = []
D.times do
  s << gets.split.map(&:to_i)
end
t = 0
ld = Array.new(26,0)
v = 0
(1..D).each do |day|
  tmpday = 0
  vv = v
  
  26.times do |i|
    tmpv = v
    tmpv += s[day-1][i]
    26.times do |j|
      next if j == i
      tmpv -= c[j] * (day - ld[j])
    end
    if tmpv > vv
      vv = tmpv
      tmpday = i
    end
  end
  
  v = vv
  
  # d 日目に選んだコンテスト
  sel = tmpday
  v += s[day-1][sel]
  ld[sel] = day
  puts sel + 1
end

Measured memory_bytes: 14284
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int MX = 110;
const int MD = 1e9 + 7;

long long memo[MX][4][4][4];

int check(int a, int b, int c) { return a == 0 && b == 2 && c == 1; }

int check(int a, int b, int c, int d) {
    if (check(a, b, c)) return false;
    if (check(b, a, c)) return false;
    if (check(a, c, b)) return false;
    if (check(b, c, d)) return false;
    if (check(c, b, d)) return false;
    if (check(b, d, c)) return false;
    if (check(a, c, d)) return false;
    if (check(a, b, d)) return false;
    return true;
}

int solve(int n, int a, int b, int c) {
    if (n == 3) return 1;
    if (memo[n][a][b][c] != -1) return memo[n][a][b][c];
    int res = 0;
    for (int i = 0; i < 4; i++) if (check(i, a, b, c))
        res = (res + solve(n - 1, i, a, b)) % MD;
    return memo[n][a][b][c] = res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	memset(memo, -1, sizeof memo);
	int n; cin >> n;
    long long ans = 0;
	for (int a = 0; a < 4; a++)
        for (int b = 0; b < 4; b++)
            for (int c = 0; c < 4; c++)
                if (check(a, b, c, -1))
                    ans = (ans + solve(n, a, b, c)) % MD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>

 int main()
{
 /*#ifndef ONLINE_JUDGE
  freopen("tin.txt","r",stdin);
  freopen("tout.txt","w",stdout);
  #endif*/
string s;
cin>>s;
reverse(s.begin(),s.end());
cout<<s<<endl;

}







Measured memory_bytes: 3036
import std.stdio;
import std.string;
import std.conv;

immutable MAX_INPUT = 1000;
immutable MAX_COUNT = 1000;

int main(string[] argv)
{
	
	int Count;
	string[] Ans;

	Count = readln().chomp().to!int();
	if(Count <= MAX_COUNT){

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

			string[] tmp = readln().chomp().split(" ");
			int[3] rect;

			rect[0] = tmp[0].to!int();
			rect[1] = tmp[1].to!int();
			rect[2] = tmp[2].to!int();

			foreach(int j;rect){
				if (!judge(j)) break;
			}

			for(int j = 0;j < 3;j++){
				if(rect[0] < rect[j]){
					int t = rect[0];
					rect[0] = rect[j];
					rect[j] = t;
				}
			}

			if(isTriangle(rect[1],rect[2],rect[0])){
				Ans ~= "YES";
			}else{
				Ans ~= "NO";
			}

		}

	}

	foreach(string str;Ans){
		writeln(str);
	}

    return 0;
}

bool judge(int x){
	if(1 <= x && x <= MAX_INPUT){
		return true;
	}
	return false;
}

bool isTriangle(int x,int y,int z){
	x = x * x;
	y = y * y;
	z = z * z;

	if (x + y == z){
		return true;
	}
	return false;
}

Measured memory_bytes: 2608
X, Y = map(int, input().split())
if X <= 3 and Y <= 3:
    ans = (4-X) * 100000 + (4-Y) * 100000
    if X == 1 and Y == 1:
        ans += 400000
elif X <= 3:
    ans = (4-X) * 100000
elif Y <= 3:
    ans = (4-Y) * 100000
else:
    ans = 0
    
print(ans)

Measured memory_bytes: 3060