akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
typedef pair <int, int> pii;
int N, M;
char A[55][55];

bool pd(int x, int y) {
  return x <= N && y <= M && A[x][y] != '#';
}

int id(int x, int y) {
  return (x - 1) * M + y;
}

int dis[55][55];
vector <pii> vec;

void dfs(int x, int y, int d) {
  if (!pd(x, y) || dis[x][y] != -1) return;
  dis[x][y] = d;
  vec.push_back(pii(x, y));
  dfs(x + 1, y, d + 1), dfs(x, y + 1, d + 1);
}

namespace Flow {
const int maxn = 10010, maxm = 2e6 + 10, inf = 1 << 30;
bool vis[maxn];
int S, T, h[maxn], f[maxn], dis[maxn], pre[maxn];

struct edges {
  int nxt, to, w, c;
  edges(int _n = 0, int _t = 0, int _w = 0, int _c = 0) :
    nxt(_n), to(_t), w(_w), c(_c) {}
} e[maxm];

queue <int> q;

void addline(int u, int v, int w, int c) {
//  printf("(%d %d) %d %d\n", u, v, w, c);
  static int cnt = 1;
  e[++cnt] = edges(h[u], v, w, c), h[u] = cnt;
  e[++cnt] = edges(h[v], u, 0, -c), h[v] = cnt;
}

bool bfs() {
  memset(dis, 0x3f, (T + 1) << 2);
  q.push(S), dis[S] = 0, f[S] = inf;
  while (!q.empty()) {
    int u = q.front();
    vis[u] = 0, q.pop();
    for (int i = h[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (e[i].w && dis[u] + e[i].c < dis[v]) {
        pre[v] = i;
        f[v] = min(f[u], e[i].w);
        dis[v] = dis[u] + e[i].c;
        if (!vis[v]) q.push(v), vis[v] = 1;
      }
    }
  }
  return dis[T] < 1e9;
}

int EK() {
  int res = 0;
//  int tmp = 0;
  while (bfs()) {
    res += f[T] * dis[T];
//    tmp += f[T];
    for (int u = T; u != S; u = e[pre[u] ^ 1].to) {
      e[pre[u]].w -= f[T], e[pre[u] ^ 1].w += f[T];
    }
  }
//  printf("#%d\n", tmp);
  return res;
}
}

void solve() {
  cin >> N >> M;
  rep(i, 1, N) {
    scanf("%s", A[i] + 1);
  }
  Flow::S = N * M * 2 + 1, Flow::T = N * M * 2 + 2;
  rep(i, 1, N) rep(j, 1, M) 
    Flow::addline(N * M + id(i, j), Flow::T, 1, 0);
  rep(i, 1, N) rep(j, 1, M) if (A[i][j] == 'o') {
    Flow::addline(Flow::S, id(i, j), 1, 0);
    vec.clear();
    memset(dis, -1, sizeof dis);
    dfs(i, j, 0);
    for (pii p : vec) {
      Flow::addline(id(i, j), N * M + id(p.first, p.second), 1, -dis[p.first][p.second]);
    }
  }
  cout << -Flow::EK() << endl;
}

signed main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 35132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    rep(i, n) {
        cin >> arr[i];
    }
    int count = 1;
    int break_num = 0;
    rep(i, n) {
        if (arr[i] == count) {
            ++count;
        } else {
            ++break_num;
        }
    }
    if (break_num == arr.size()) {
        cout << "-1" << endl;
    } else {
        cout << break_num << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  LL Z = max(X, Y);
  LL vmin = LLONG_MAX;
  for (LL i = 0; i <= Z; ++i) {
    LL cost = 2LL * i * C;
    if (X - i > 0) cost += A * (X-i);
    if (Y - i > 0) cost += B * (Y-i);
    vmin = min<LL>(vmin, cost);
  }
  cout << vmin << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    double r;
    cin >> r;
    double pi = acos(-1);
    double ans = r * 2 * pi;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}


Measured memory_bytes: 3804
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const R=input[0],G=input[1],B=input[2],N=input[3];
  const dp=[[],[],[],[],];
  /*dp[i][j]はRGBの前からi色を使って
  のこりの玉をjにのする場合の数*/
  for(let i=0;i<=3;i++){
    for(let j=0;j<=N+R+G+B;j++){
      dp[i][j]=0;
    }
  }
  
  dp[0][N]=1;
  
  for(let i=1;i<=3;i++){
    for(let j=N;j>=0;j--){
      dp[i][j]+=dp[i-1][j]+dp[i][j+input[i-1]];
    }
  }
  console.log(dp[3][0]);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 8140
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        WriteLine((H - h) * (W - w));
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int k; cin >> k;
	ll ans = 0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int kk=1; kk<=k; kk++){
				ans += __gcd(i,__gcd(j,kk));
			}
		}
	}
	cout << ans << endl;
}	
/*  Benq's (modified)
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a==b&&a!=c&&b!=c||a==c&&a!=b&&c!=b||b==c&&b!=a&&c!=a)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
abcd = [list(map(int, input(). split())) for _ in range(q)]

points = []
for able in itertools.combinations_with_replacement(range(1, m+1), n):
    point = 0
    for a, b, c, d in abcd:
        if able[b-1] - able[a-1] == c:
            point += d
    points.append(point)

print(max(points))


Measured memory_bytes: 79952
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,N,M,bf=-1,ans=0,cnt=0;
  cin>>N>>M;
  vec a(N),sum(N+1,0);
  rep(i,N){
    cin>>a[i];
    sum[i+1]=(sum[i]+a[i])%M;
  }
  vsort(sum);
  rep(i,N+1){
    if(bf==sum[i]){
      cnt++;
    }else{
      ans+=cnt*(cnt+1)/2;
      cnt=0;
      bf=sum[i];
    }
  }
  ans+=cnt*(cnt+1)/2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

struct Fish
{
    ll beauty;
    ll taste;
};

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> X(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> X[i];
    }

    ll sum = 0;
    for (ll i = 0; i < N; i++)
    {
        sum += min(X[i], abs(X[i] - K));
    }
    cout << sum * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX 100010

using namespace std;

int n,m,ans,pa,x,y;
int p[MAX],acca[MAX];
bool acc[MAX];
vector<int> nd[MAX],na;
void dfs(int nod){
  acc[nod]=true;
  acca[nod]=pa;
  na.push_back(p[nod]);
  for(auto i:nd[nod])
    if(not acc[i]){
      acc[i]=true;
      acca[i]=pa;
      dfs(i);
    }
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=1;i<=m;i++)
      cin>>x>>y,
      nd[x].push_back(y),
      nd[y].push_back(x);
    for(int i=1;i<=n;i++)
      if(not acc[i]){
        pa=i;na.clear();
        dfs(i);
        for(auto j:na)
          if(acca[j]==i)ans++;
      }
    cout<<ans;
    return 0;
}


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

using namespace std;

bool judge (char c)
{
    if (c=='y' || c=='u' || c=='i' || c=='o' || c=='p' || c=='h' || c=='j' || c=='k' || c=='l' || c=='n' || c=='m') return true;
    else return false;
}

int main()
{
    while (1)
    {
        int ans=0; bool hand;
        string s; char c;
        cin>>s;
        if (s=="#") break;
        c=s[0];
        hand=judge(c);
        for (int i=1; i<s.size(); i++)
        {
            c=s[i];
            if (judge(c)!=hand) { ans++; hand=!hand; }
        }
        cout<<ans<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    int n;
    ll sum1 = 0, sum2 = 0, ans = -(1LL << 62);
    scanf("%d", &n);
    vector<ll> a(3 * n);
    for (int i = 0; i < 3 * n; ++i) scanf("%lld", &a.at(i));
    multiset<ll> s1, s2;
    vector<ll> d1(n + 1), d2(n + 1);
    for (int i = 0; i < n; ++i) sum1 += a.at(i), s1.insert(a.at(i));
    d1.at(0) = sum1;
    for (int i = n; i < 2 * n; ++i) {
        if (a.at(i) > *s1.begin()) sum1 += a.at(i) - *s1.begin(), s1.erase(s1.begin()), s1.insert(a.at(i));
        d1.at(i - n + 1) = sum1;
    }
    for (int i = 3 * n - 1; i >= 2 * n; --i) sum2 += a.at(i), s2.insert(a.at(i));
    d2.at(n) = sum2;
    for (int i = 2 * n - 1; i >= n; --i) {
        if (a.at(i) < *s2.rbegin()) sum2 += a.at(i) - *s2.rbegin(), s2.erase(--s2.end()), s2.insert(a.at(i));
        d2.at(i - n) = sum2;
    }
    for (int i = 0; i <= n; ++i) ans = max(ans, d1.at(i) - d2.at(i));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;i++)
#define MAX 200000000
using namespace std;
int main(void)
{
	int n,m;
	int a,b,c,di;
	int s,g,v,p;
	int d[21][21];
	char ch;
	cin>>n>>m;
	rep(i,n)rep(j,n)d[i][j]=(i==j)?0:MAX;
	rep(i,m){
		cin>>a>>ch>>b>>ch>>c>>ch>>di;
		d[a][b]=c;
		d[b][a]=di;
	}
	rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	cin>>s>>ch>>g>>ch>>v>>ch>>p;
	cout<<v-p-d[s][g]-d[g][s]<<endl;
	return 0;
}


Measured memory_bytes: 3020
//********************
//*@Author:  ChenShou*
//*@Language:C++11   *
//********************

#include<bits/stdc++.h>

//#pragma comment ( linker ," /STACK:102400000 , 102400000 " )
//#define DEBUG
#define RI register int 
#define endl "\n"

using namespace std ;

typedef long long ll ;
// typedef __int128 lll ;
const int N = 100000  + 10 ;
const int M = 1000000 + 10 ;
const int MOD = 1e9 + 7 ; 
const double PI = acos(-1.0) ;
const double EXP = 1E-9 ;
const int INF = 0x3f3f3f3f;

inline ll read(){
    long long x = 0 , f = 1 ;
    char ch = getchar() ;
    while(ch<'0'||ch>'9'){
        if(ch == '-') f = -1 ;
        ch = getchar();
    }
    while(ch >='0' && ch <= '9' ){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x*f ;
}

ll f_t(ll n){
	return (n*n*n*n*n);
}

void solve(){
	ll n=read();
	for(ll i=-1000;i<=1000;i++){
		for(int j=-1000;j<=1000;j++){
			if(f_t(i)-f_t(j)==n){
				cout<<i<<' '<<j<<endl;
				return ;
			}
		}
	}
	return ;
}

int main(){
#ifdef DEBUG
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
	//for(ll T=read();T;T--)
		solve();
#ifdef DEBUG
    printf("\nHellow , Mr.ChenShou\n");
    printf("\t Time cost : %lf s \n",(double)clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
int main(){
  int r,c,i,j,sum=0;
  int inf[101][101],sum1[102]={};
  int sum2[102]={};

  scanf("%d %d",&r,&c);

  for(i=1;i<=r;i++){
    for(j=1;j<=c;j++){
      scanf("%d",&inf[i][j]);
      sum1[i]+=inf[i][j];
    }
    sum+=sum1[i];
  }
  for(j=1;j<=c;j++){
    for(i=1;i<=r;i++){
      sum2[j]+=inf[i][j];
    }
  }
  for(i=1;i<=r+1;i++){
    for(j=1;j<=c+1;j++){
      if(i==r+1 && j==c+1){
	printf("%d\n",sum);
      }else if(j==c+1){
	printf("%d\n",sum1[i]);
      }else if(i==r+1){
	printf("%d ",sum2[j]);
      }else{
	printf("%d ",inf[i][j]);
      }
    }
  }
  return 0;
}

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

int gcd( int a, int b )
{
	if( a == 0 )
	{
		return b;
	}
	else
	{
		return gcd( b%a, a );
	}
}
int main()
{
	int n;
	cin >> n;
	vector<int> a( n );
	for( int i = 0; i < n; ++i )
	{
		cin >> a[i];
	}

	vector< int > r( n+1 ), l( n+1 );
	l[0] = 0;
	for( int i = 0; i < n; i++ )
	{
		l[i+1] = gcd( l[i], a[i] );
	}

	r[n - 1] = 0;
	for( int i = n; i > 0; i-- )
	{
		r[i - 1] = gcd( r[i], a[i - 1] );
	}

	int ans = 0;
	for( int i = 0; i < n; ++i )
	{
		ans = max( ans, gcd(l[i], r[i+1]) );
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int n, i, a, mina=1001, maxa=0;
  cin >> n; 
  
  for (i=0; i<n; i++) {
    cin >> a;
    if (a < mina) mina = a;
    if (a > maxa) maxa = a;
  }
  cout << maxa - mina << endl;
   
  return 0;  
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;
int p[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    int m = 0;
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        s += p[i];
        m = max(m , p[i]);
    }
    cout << s - m / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();


        if (A == B && B == C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    HAPPY = [list(map(int, input().split())) for i in range(N)]
    dp = [[0]*3 for i in range(N+1)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][k] = max(dp[i+1][k], HAPPY[i][k] + dp[i][j])
    print(max(max(dp[N][0], dp[N][1]), dp[N][2]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69724
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll r,d,x,i;
    cin>>r>>d>>x;
    for(i=1;i<=10;i++){
        cout<<r*x-d<<endl;
        x=r*x-d;
    }
    return 0;
}


Measured memory_bytes: 256
a, b = [int(input()) for i in range(2)]

if a == 1 and b == 2:
    print(3)
elif a == 2 and b == 1:
    print(3)
elif a == 2 and b == 3:
    print(1)
elif a == 3 and b == 2:
    print(1)
elif a == 1 and b == 3:
    print(2)
elif a == 3 and b == 1:
    print(2)


Measured memory_bytes: 3060
s = input()
t = input()

alpha2num = lambda c: ord(c) - ord('a')

a2n = [[] for i in range(26)]

for i in range(len(s)):
    if len(a2n[alpha2num(t[i])]) == 1:
        if a2n[alpha2num(t[i])][0] != alpha2num(s[i]):
            print('No')
            exit()
        else:
            continue
    
    a2n[alpha2num(t[i])].append(alpha2num(s[i]))
    
a2n = [[] for i in range(26)]

for i in range(len(s)):
    if len(a2n[alpha2num(s[i])]) == 1:
        if a2n[alpha2num(s[i])][0] != alpha2num(t[i]):
            print('No')
            exit()
        else:
            continue
    
    a2n[alpha2num(s[i])].append(alpha2num(t[i]))
        
print('Yes')

Measured memory_bytes: 3632
function Main(input) {
	input = input.trim();
	var N = parseInt(input, 10);
	var vec_p = [];
	var vec_e = [];
	var tmpN = N;
	var j = 0;
	var k = 0;
	var ans = 0;
	var checkTmpN = 1;
	var tmp;
	for (var i = 2; i <= Math.sqrt(N); i++){
		j = 0;
		same_number:
		while (true) {
			if (tmpN % i === 0){
				j ++;
				tmpN = tmpN / i ;
				checkTmpN *= i;
				if (j === 1) {
					vec_p.push(i);
					vec_e.push(1);
					k++;
				} else {
					vec_e[k - 1] ++;
				}
			} else {
				break same_number;
			}
		}
	}
	if (checkTmpN !== N) {
		vec_p.push(N / checkTmpN);
		vec_e.push(1);
	}
	for (var i = 0; i < vec_e.length; i++){
		tmp = Math.floor((Math.sqrt(1 + (8 * vec_e[i])) - 1) / 2);
		ans += tmp;
	}
 	console.log(ans);	
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33248
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  string s; cin >> s;
  int n = s.size()-1;
  if(s[n] == '0' || s[n] == '1' || s[n] == '6' || s[n] == '8') cout << "pon\n";
  if(s[n] == '2' || s[n] == '4' || s[n] == '5' || s[n] == '7' || s[n] == '9') cout << "hon\n";
  if(s[n] == '3' ) cout << "bon\n";
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = (1LL << 31) - 1;

template <class T>
struct DelaySegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<int> node, delay_val, delay_add;
  vector<bool> delayflag;

  DelaySegmentTree(vector<T> v ,T inf, F f) : inf(inf), f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1, inf);
    delay_val.resize(2*n-1, inf);
    delay_add.resize(2*n-1, 0);
    delayflag.resize(2*n-1, false);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1], node[2*i+2]);
  }

  void eval(int k, int l, int r){
    if(delayflag[k]){
      //node[k] = delay_val[k] * (r - l); //区間sum
      node[k] = delay_val[k]; //区間min(max)
      if(r - l > 1){
        delay_val[2*k+1] = delay_val[2*k+2] = delay_val[k];
        delayflag[2*k+1] = delayflag[2*k+2] = true;
      }
      delayflag[k] = false;
    }
    if(delay_add[k] != 0){
      node[k] += delay_add[k]; //区間sum
      //node[k] += delay_add[k] / (r - l); //区間min(max)
      if(r - l > 1){
        delay_add[2*k+1] += delay_add[k] / 2;
        delay_add[2*k+2] += delay_add[k] / 2;
      }
      delay_add[k] = 0;
    }
  }

  void update(int a, int b, T x){ update(a, b, x, 0, 0, n); }
  void update(int a, int b, T x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay_val[k] = x;
      delayflag[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);
      node[k] = f(node[2*k+1], node[2*k+2]);
    }
  }

  void add(int a, int b, T x){ add(a, b, x, 0, 0, n); }
  void add(int a, int b, T x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay_add[k] += x * (r - l);
      eval(k, l, r);
    }else{
      add(a, b, x, 2*k+1, l, (l+r)/2);
      add(a, b, x, 2*k+2, (l+r)/2, r);
      node[k] = f(node[2*k+1], node[2*k+2]);
    }
  }

  //区間[a, b)の値を返す
  T getval(int a, int b){ return getval(a, b, 0, 0, n); }
  T getval(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n, q; cin >> n >> q;
  DelaySegmentTree<int> seg(vector<int>(n, INF), INF, [&](int x, int y){ return min(x, y); });
  for(int i = 0; i < q; i++){
    int c, s, t, x; cin >> c >> s >> t;
    //s--, t--;
    if(c == 0){
      cin >> x;
      seg.update(s, t+1, x);
    }else{
      cout << seg.getval(s, t+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
ll a[maxn];
int main() {
	int n;
	cin >> n;
	ll sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum1 += a[i]; sum2 += a[i] * a[i];
	}
	ll x1 = sum1 / n;
	ll x2 = sum1 / n + 1;
	if (2 * sum1 < n * (2 * x1 + 1)) {
		cout << sum2 - 2 * sum1 * x1 + n * x1 * x1 << endl;
	} else {
		cout << sum2 - 2 * sum1 * x2 + n * x2 * x2 << endl;
	}
	return 0;
}
/*
2 * sum1 * (x1 + 1) - 2 * sum1 * x1 + n * x1 * x1 - n * (x1 + 1) * (x1 + 1)
2 * sum1 + n * x1 * x1 - n * (x1 + 1) * (x1 + 1)
2 * sum1 + n * x1 * x1 - n * (x1 * x1 + 2 * x1 + 1)
2 * sum1 - n * (2 * x1 + 1);
*/

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

#define N 50

int h, w;
char s[N][N];

int dp[N][N];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int walk()
{
	queue<pair<int, int>> que;
	que.push({ 0, 0 });
	dp[0][0] = 0;
	while( !que.empty() ) {
		auto q = que.front();
		que.pop();
		int x = q.first;
		int y = q.second;

		if( x == w - 1 && y == h - 1 ) {
			return dp[x][y];
		}

		for( int d = 0; d < 4; d++ ) {
			int xx = x + dx[d];
			int yy = y + dy[d];
			if ( 0 <= xx && xx < w && 0 <= yy && yy < h ) {
				if ( s[xx][yy] != '#' && dp[xx][yy] == -1 ) {
					dp[xx][yy] = dp[x][y] + 1;
					que.push({ xx, yy });
				}
			}
		}
	}
	return 0;
}

int main()
{
	int ans;
	int len, black = 0;

	cin >> h >> w;
	for ( int i = 0; i < h; i++ ) {
		for ( int j = 0; j < w; j++ ) {
			cin >> s[j][i];
		}
	}

	for ( int i = 0; i < h; i++ ) {
		for ( int j = 0; j < w; j++ ) {
			dp[j][i] = -1;
		}
	}
	len = walk();
	if( len == 0 ) {
		ans = -1;
	}
	else {
		
		for ( int i = 0; i < h; i++ ) {
			for ( int j = 0; j < w; j++ ) {
				if( s[j][i] == '#' ) {
					black++;
				}
			}
		}
		ans = h*w - black - len - 1;
	}

	cout << ans << endl;

	return 0;
}


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

size_t search_nearest_left_R(char* str,size_t now_pos){
    for(size_t i=1;;i++){
        if(str[now_pos-i]=='R'){
            return now_pos-i;
        }
    }
}

size_t search_nearest_right_L(char* str,size_t now_pos){
    for(size_t i=1;;i++){
        if(str[now_pos+i]=='L'){
            return now_pos+i;
        }
    }
}

int main()
{
    using uint = unsigned int;
    constexpr uint N_MAX = 100000;
    char s[N_MAX];
    std::cin >> s;
    
    uint ans[N_MAX]={};
    const size_t N = std::strlen(s);
    
    size_t nearest_left_R = 0;//今の位置から一番近い左側のR
    size_t nearest_right_L = search_nearest_right_L(s,0);//今の位置から一番近い右側のL
    
    for(size_t i =0; i < N; i++){
       if(s[i] == 'R'){
           const size_t distance_to_L = nearest_right_L - i;//一番近い右側のLまでの移動回数
           if( distance_to_L % 2 == 0){
               ans[nearest_right_L]++;
           }else{
               ans[nearest_right_L - 1]++;
           }
           nearest_left_R = i;//一番近い左側のRを更新
       }else{//s[i] == 'L'
           const size_t distance_to_R = i - nearest_left_R;//一番近い左側のRまでの移動回数 
           if( distance_to_R % 2 == 0){
               ans[nearest_left_R]++;
           }else{
               ans[nearest_left_R + 1]++;
           }
           nearest_right_L = search_nearest_right_L( s , i );//一番近い右側のLを更新
       }
    }
    
    for(size_t i=0; i < N; i++){
        std::cout<<ans[i]<<" ";
    }
    std::cout<<std::endl;
    
    return 0;
}


Measured memory_bytes: 896
use proconio::input;

fn main() {
    input! {
        N: usize,
        A: [f64; N]
    };

    let mut value = 1.0 / A[0];

    for v in &A[1..] {
        value += 1.0 / v;
    }

    println!("{}", 1.0 / value);
}


Measured memory_bytes: 2232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s, t;
	cin >> s >> t;
	string u = s + t;
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
		if (i < t.size())cout << t[i];
	}
	cout << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int64_t> x_vec(N), y_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> x_vec.at(i) >> y_vec.at(i);
    vector<int64_t> x_y_1_vec(N), x_y_2_vec(N);
    for (int i = 0; i < N; ++i) {
        x_y_1_vec.at(i) = x_vec.at(i) + y_vec.at(i);
        x_y_2_vec.at(i) = x_vec.at(i) - y_vec.at(i);
    }
    int64_t max_x_y_1 = *max_element(x_y_1_vec.begin(), x_y_1_vec.end());
    int64_t min_x_y_1 = *min_element(x_y_1_vec.begin(), x_y_1_vec.end());
    int64_t max_x_y_2 = *max_element(x_y_2_vec.begin(), x_y_2_vec.end());
    int64_t min_x_y_2 = *min_element(x_y_2_vec.begin(), x_y_2_vec.end());
    int64_t max_dist_1 = max_x_y_1 - min_x_y_1;
    int64_t max_dist_2 = max_x_y_2 - min_x_y_2;
    cout << max(max_dist_1, max_dist_2) << endl;
}



Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200005] ;
long long f[200005][5] ;
int main()
{
    scanf("%d",&n) ;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        scanf("%d",&a[i]) ;
    }
    for(int i = 1;i <= n;i++) {
        f[i][0] = f[i - 1][0] + a[i] ;
        f[i][1] = min(f[i - 1][0] , f[i - 1][1]) + (a[i] % 2 == 1) ;
        f[i][2] = min(f[i - 1][1] , min(f[i-1][0],f[i - 1][2])) + (a[i] % 2 == 0) ;
        f[i][3] = min(f[i - 1][2] , f[i - 1][3]) + (a[i] % 2 == 1) ;
        f[i][4] = min(f[i - 1][3] , min(f[i - 1][1] , min(f[i-1][2] , f[i - 1][4]))) + a[i] ;
        if(a[i] == 0) {f[i][1]+=2 ; f[i][3]+=2 ;}
    }
    printf("%lld\n",min(f[n][0] , min(f[n][1] , min(f[n][2] , min(f[n][3] , f[n][4])))));
    return 0;
}


Measured memory_bytes: 8832
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 200005
long long  n,a[N],c[N];
int main(){
    scanf("%lld",&n);
    for (int i = 1;i <= n;i++){
        scanf("%lld",&a[i]);
        a[i] -= i;
    }
    sort(a+1,a+1+n);long long b = a[(n+1)/2],ans = 0;
    for(int i = 1;i <= n;i++){
        ans += abs(a[i] - b);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


int main() {
	string s, t;
	cin >> s >> t;
	int sz = s.size();
	int tz = t.size();
	
	bool ok = 0;
	for(int i = sz - tz; i >= 0; i--){
		int ind_i = i;
		int flag = 0;
		for(int j = 0; j < tz; j++){
			if(s[ind_i] != t[j] && s[ind_i] != '?')
				flag = 1;
			ind_i++;
		}
		
		
		if(flag == 0){
			ind_i = i;
			for(int j = 0; j < tz; j++){
				s[ind_i] = t[j];
				ind_i++;
			}
			ok = 1;
			break;
		}
	}
		if(ok == 0){
			cout << "UNRESTORABLE" << endl;
		}else{
			for(int i = 0; i < sz; i++){
				if(s[i] == '?')
					s[i] = 'a';
			}
			
			cout << s << endl;
		}
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[10000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
  for ( int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  for( int h = 1; ;) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);
  
  cout << G.size()  << endl;

  for ( int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 7184
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=5e5+5;
vector<int>g[maxm];
char s[maxm];
int in[maxm];
int d[maxm];
int n;
signed main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    n++;
    for(int i=1;i<=n-1;i++){
        if(s[i]=='>'){
            g[i+1].push_back(i);
            in[i]++;
        }else{
            g[i].push_back(i+1);
            in[i+1]++;
        }
    }
    queue<int>q;
    for(int i=1;i<=n;i++){
        if(in[i]==0){
            q.push(i);
        }
    }
    int ans=0;
    while(!q.empty()){
        int x=q.front();q.pop();
        ans+=d[x];
        for(int v:g[x]){
            if(in[v]){
                in[v]--;
                d[v]=max(d[v],d[x]+1);
                if(!in[v]){
                    q.push(v);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 39332
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const int SZE = 1e6+1;

int r[3009];//1 indexed
char s[3009];
int rs[3009];//1 indexed
LL mm[3009][3009];

int n,m;

LL dp(int p,int v){
	if(p==n)return (v==0);
	if(v>r[p]-p)return 0;
	if(mm[p][v]!=-1)return mm[p][v];
	int dv=0;
	if(r[p+1]>r[p])dv=rs[r[p+1]]-rs[r[p]];
	mm[p][v]=dp(p+1,v+dv);
	if(v+dv)mm[p][v]=(mm[p][v]+dp(p+1,v+dv-1))%MOD;
	return mm[p][v];
}

int main(){
	RII(n,m);
	RS(s);
	REPP(i,1,n+1){
		rs[i]=rs[i-1]+(s[i-1]=='1');
	}
	REP(i,m){
		DRII(a,b);
		r[a]=max(r[a],b);
	}
	REPP(i,1,n+1){
		r[i]=max(max(i,r[i]),r[i-1]);
	}
	MS1(mm);
	printf("%lld\n",dp(0,0));
	/*REP(i,n+1){
		REP(j,n){
			printf("%lld ",dp(i,j));
		}puts("");
	}*/
}


Measured memory_bytes: 71296
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int rel[n];
rel[0]=0;
rel[1]=abs(arr[0]-arr[1]);
for(int i=2;i<n;i++)
{
rel[i]=min(rel[i-1]+abs(arr[i-1]-arr[i]),rel[i-2]+ abs(arr[i-2]-arr[i]));
}
cout<<rel[n-1]<<endl;
return 0;
}

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

public class Main {

	/** 区切り文字 */
	static final String REGEX = ",";

	/** インキ滴の小 */
	static final int SMALL_SIZE = 1;

	/** インキ滴の中 */
	static final int MIDIAM_SIZE = 2;

	/** インキ滴の大 */
	static final int LARGE_SIZE = 3;

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int[] field = new int[101];
		int x;
		int y;
		int size;
		while (true) {
			String line = reader.readLine();
			if (line == null || line.isEmpty()) {
				break;
			}
			String[] str = line.split(REGEX);
			x = Integer.valueOf(str[0]);
			y = Integer.valueOf(str[1]);
			size = Integer.valueOf(str[2]);

			switch (size) {
			case SMALL_SIZE:
				drowSmallArea(field, x, y);
				break;
			case MIDIAM_SIZE:
				drowSmallArea(field, x, y);
				drowMidiumArea(field, x, y);
				break;
			case LARGE_SIZE:
				drowSmallArea(field, x, y);
				drowMidiumArea(field, x, y);
				drowLargeArea(field, x, y);
				break;
			default:
			}
		}

		int count = 0;
		int max = 0;
		for (int i = 0; i < 100; i++) {
			if (field[i] == 0) {
				count++;
			}
			if (field[i] > max) {
				max = field[i];
			}
		}

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

	/**
	 * x座標とy座標を受け取って、配列のインデックスを返却する。
	 *
	 * @param x
	 *            x座標
	 * @param y
	 *            y座標
	 * @return 配列のインデックス
	 */
	private static int calcIndex(int x, int y) {
		if (x < 0 || y < 0 || x > 9 || y > 9) {
			return 100;
		}
		return (x * 10) + y;
	}

	/**
	 * 小サイズ領域をインクで染める
	 *
	 * @param field
	 *            フィールド
	 * @param x
	 *            x座標
	 * @param y
	 *            y座標
	 */
	private static void drowSmallArea(int[] field, int x, int y) {
		field[calcIndex(x - 1, y)] += 1;
		field[calcIndex(x, y + 1)] += 1;
		field[calcIndex(x, y)] += 1;
		field[calcIndex(x, y - 1)] += 1;
		field[calcIndex(x + 1, y)] += 1;
	}

	/**
	 * 中サイズ領域をインクで染める
	 *
	 * @param field
	 *            フィールド
	 * @param x
	 *            x座標
	 * @param y
	 *            y座標
	 */
	private static void drowMidiumArea(int[] field, int x, int y) {
		field[calcIndex(x - 1, y + 1)] += 1;
		field[calcIndex(x - 1, y - 1)] += 1;
		field[calcIndex(x + 1, y + 1)] += 1;
		field[calcIndex(x + 1, y - 1)] += 1;
	}

	/**
	 * 大サイズ領域をインクで染める
	 *
	 * @param field
	 *            フィールド
	 * @param x
	 *            x座標
	 * @param y
	 *            y座標
	 */
	private static void drowLargeArea(int[] field, int x, int y) {
		field[calcIndex(x - 2, y)] += 1;
		field[calcIndex(x, y + 2)] += 1;
		field[calcIndex(x, y - 2)] += 1;
		field[calcIndex(x + 2, y)] += 1;
	}
}

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

class Main {
    static String[] cards;
    static int[] nums;
    static int[] check; // stable or not stable
    static int n;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        n = Integer.parseInt(br.readLine());
        cards = new String[n];
        nums = new int[n];
        check = new int[n];

        for (int i = 0; i < n; i++) {
            cards[i] = br.readLine();
            nums[i] = Integer.parseInt(cards[i].split(" ")[1]);
            check[i] = i;
        }

        quickSort(nums, 0, n - 1);

        if (isStable()) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }

        for (String s : cards) {
            System.out.println(s);
        }

    }

    static boolean isStable() {
        for (int i = 0; i < n - 1; i++) {
            if (nums[i] == nums[i + 1]){
                if(check[i] > check[i+1]){
                    return false;
                }
            }
        }
        return true;
    }

    static void quickSort(int[] A, int p, int r) {
        if (p < r) {
            int q = partition(A, p, r);
            quickSort(A, p, q - 1);
            quickSort(A, q + 1, r);
        }
    }

    static int partition(int[] A, int p, int r) {
        int x = A[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (A[j] <= x) {
                i++;
                swap(A, i, j);
            }
        }
        swap(A, i + 1, r);
        return i + 1;
    }

    static void swap(int[] A, int x, int y) {
        int tmp = A[x];
        A[x] = A[y];
        A[y] = tmp;

        String tmps = cards[x];
        cards[x] = cards[y];
        cards[y] = tmps;

        tmp = check[x];
        check[x] = check[y];
        check[y] = tmp;
    }

}



Measured memory_bytes: 74260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

typedef struct EdgeInfo{
    ll from;
    ll to;
    ll cost;
    EdgeInfo() {};
    EdgeInfo(ll _from, ll _to, ll _cost) : from(_from), to(_to), cost(_cost) {};
} edge;

ll N, M, P; 
vector<vector<ll>> G1, G2;
vector<bool> fzero, fn;

void dfs(ll now, vector<vector<ll>> &G, vector<bool> &v){
    if(v[now]) return;
    v[now] = true;
    for(auto g : G[now]){
        dfs(g, G, v);
    }
}

int main(){

    cin >> N >> M >> P;
    vector<edge> E(M);
    G1.resize(N);
    G2.resize(N);
    fzero.resize(N, false);
    fn.resize(N, false);
    rep(i, 0, M){
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--; w -= P;
        E[i] = edge (u, v, -w);
        G1[u].push_back(v);
        G2[v].push_back(u);
    }

    cerr << "hoge" << endl;
    
    dfs(0, G1, fzero);
    dfs(N-1, G2, fn);

    vector<ll> d(N, 1e18);
    bool closed_loop = false;

    ll srt = 0;
    d[srt] = 0;
    rep(i, 0, N){
        rep(j, 0, M){
            auto e = E[j];
            if(!(fzero[e.from] && fn[e.to])) continue;
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                if(i == N-1){
                    closed_loop = true;
                    break;
                }
            }
        }
    }

    if(closed_loop) cout << -1 << endl;
    else cout << max(0LL, -d[N-1]) << endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int N;
long A[1<<17],S[1<<17],T[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)
	{
		S[i+1]=S[i]+(i%2==0?A[i]:0);
		T[i+1]=T[i]+(i%2==0?0:A[i]);
	}
	for(int i=0;i<N;i++)
	{
		long now=S[N]-S[i]+T[i]-(T[N]-T[i]+S[i]);
		cout<<(i%2==0?now:-now)<<endl;
	}
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

#define INF 0

int main(void)
{
    int K, N;
    cin >> K >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i)
        cin >> vec[i];
    int min_d = vec[0] + K - vec[N - 1];
    for (int i = 0; i < N - 1; ++i)
        min_d = max(min_d, abs(vec[i + 1] - vec[i]));
    cout << K - min_d << "\n";
}

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

string decode(string s) {
	for (int a=1; a<26; ++a) {
		for (int b=0; b<26; ++b) {
			string t = "";
			for (int i=0; i<(int)s.size(); ++i) {
				if (s[i] == ' ') {
					t += ' ';
				} else {
					t += char('a' + (a * (s[i] - 'a' + b)) % 26);
				}
			}
			if (t.find("this") != string::npos || t.find("that") != string::npos) {
				return t;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	cin.ignore();
	string s;
	while (n--) {
		getline(cin, s);
		cout << decode(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int A[5]; for (auto &a : A) cin >> a;
    int ans = 1e9;
    for (int i = 0; i < 5; i++) {
        int t = 0;
        for (int j = 0; j < 5; j++) {
            if (i != j) t += (A[j] + 9) / 10 * 10;
            else t += A[j];
        }
        ans = min(ans, t);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <stdio.h>
using namespace std;

struct Cell {
	double x, y, z, r;
};

struct Edge {
	int to;
	double distance;
	bool operator <(const Edge &a) const {
		return distance > a.distance;
	}
};

Cell cells[101];
bool visited[101];
double distances[101][101];

int main() {
	int n;
	while(true) {
		cin >> n;
		if(n == 0)
			break;
		for (int i = 0; i < n; i++) {
			cin >> cells[i].x >> cells[i].y >> cells[i].z >> cells[i].r;
			visited[i] = false;
			for (int j = 0; j < i; j++) {
				distances[i][j] = distances[j][i]
					= max(0.0,
						sqrt(pow(cells[i].x - cells[j].x, 2) + pow(cells[i].y - cells[j].y, 2)
						+ pow(cells[i].z - cells[j].z, 2))
						- cells[i].r - cells[j].r
					);
			}
		}
		priority_queue<Edge> pq;
		int current_vertex = 0;
		double length = 0;

		for (int i = 0; i < n - 1; i++) {
			visited[current_vertex] = true;
			for (int j = 0; j < n; j++) {
				if(!visited[j]) {
					Edge e;
					e.to = j;
					e.distance = distances[current_vertex][j];
					pq.push(e);
				}
			}
			while(!pq.empty()) {
				Edge e = pq.top();
				pq.pop();
				if(!visited[e.to]) {
					current_vertex = e.to;
					length += e.distance;
					//cout << "goto:" << e.to << ", dist:" << e.distance << endl;
					break;
				}
			}
		}
		printf("%.3f\n", length);
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX_N 105
using namespace std;

char s[10];
int op[2]={1,-1};
char ss[2]={'+','-'};

int main(){
    int i,j,k;
    int x,y,z;

    scanf("%s",s);

    for(i=0;i<4;i++) s[i] -='0';

    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            for(k=0;k<2;k++){
                x=s[0]+op[i]*s[1]+op[j]*s[2]+op[k]*s[3];
                if(x==7){
                    printf("%d%c%d%c%d%c%d=%d",s[0],ss[i],s[1],ss[j],s[2],ss[k],s[3],7);
                    return 0;
                }
            }
        }
    }


    return 0;
}


Measured memory_bytes: 128
# 15:35-

n = int(input())
s = input() 

o = "o"
x = "x"

sheep = "S"
wolf = "W"

ans = [None] * n

ans[0] = sheep 
ans[1] = sheep 
for i, c in enumerate(s[1:-1]):
  if ((c == o) == (ans[i+1] == sheep)) == (ans[i] == sheep):
    ans[i+2] = sheep
  else:
    ans[i+2] = wolf

if ((s[0] == o) == (ans[0] == sheep)) == (ans[1] == ans[-1]):
  if ((s[-1] == o) == (ans[-1] == sheep)) == (ans[0] == ans[-2]):
    print("".join(ans))
    exit()

ans[0] = sheep 
ans[1] = wolf
for i, c in enumerate(s[1:-1]):
  if ((c == o) == (ans[i+1] == sheep)) == (ans[i] == sheep):
    ans[i+2] = sheep
  else:
    ans[i+2] = wolf

if ((s[0] == o) == (ans[0] == sheep)) == (ans[1] == ans[-1]):
  if ((s[-1] == o) == (ans[-1] == sheep)) == (ans[0] == ans[-2]):
    print("".join(ans))
    exit()

ans[0] = wolf
ans[1] = sheep 
for i, c in enumerate(s[1:-1]):
  if ((c == o) == (ans[i+1] == sheep)) == (ans[i] == sheep):
    ans[i+2] = sheep
  else:
    ans[i+2] = wolf

if ((s[0] == o) == (ans[0] == sheep)) == (ans[1] == ans[-1]):
  if ((s[-1] == o) == (ans[-1] == sheep)) == (ans[0] == ans[-2]):
    print("".join(ans))
    exit()

ans[0] = wolf
ans[1] = wolf
for i, c in enumerate(s[1:-1]):
  if ((c == o) == (ans[i+1] == sheep)) == (ans[i] == sheep):
    ans[i+2] = sheep
  else:
    ans[i+2] = wolf

if ((s[0] == o) == (ans[0] == sheep)) == (ans[1] == ans[-1]):
  if ((s[-1] == o) == (ans[-1] == sheep)) == (ans[0] == ans[-2]):
    print("".join(ans))
    exit()

print(-1)

  

Measured memory_bytes: 4456