akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long unsigned int ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n, max_w;
    cin >> n >> max_w;

    vector< int > w;
    vector< int > v;

    REP(i,n){
        int temp_w, temp_v;
        cin >> temp_w >> temp_v;
        w.push_back(temp_w);
        v.push_back(temp_v);
    }

    vector< ll > dp[101];

    REP(i,max_w + 1){
        dp[0].push_back(0);
    }

    REP(i,n){
        REP(j,max_w + 1){
            if(j < w[i]){
                dp[i+1].push_back(dp[i][j]);
            }else{
                dp[i+1].push_back(max(dp[i][j], dp[i][j-w[i]] + v[i]));
            }
        }
    }

    cout << *max_element(dp[n].begin(), dp[n].end()) << endl;

    return 0;
}

Measured memory_bytes: 80244
#include <climits>
#include <cstdio>
#include <iostream>

const int INF = INT_MAX/10;

using namespace std;

const int V_MAX = 10;
const int E_MAX = 45;

typedef pair<int, int> P; // v, cost

int main() {
  int N;
  while (cin >> N) {
    int V = 0;
    int d[V_MAX][V_MAX];
    if (N == 0) break;
    for (int i = 0; i < V_MAX; i++) {
      for (int j = 0; j < V_MAX; j++) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = INF;
      }
    }
    for (int i = 0; i < N; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      d[a][b] = c;
      d[b][a] = c;
      V = max(V, a); V = max(V, b);
    }
    for (int k = 0; k <= V; k++) {
      for (int i = 0; i <= V; i++) {
        for (int j = 0; j <= V; j++) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    int m = INF;
    int ans = -1;
    for (int i = 0; i <= V; i++) {
      int sum = 0;
      for (int j = 0; j <= V; j++) {
        if (i != j) {
          if (d[i][j] != INF) {
            sum += d[i][j];
          }
        }
      }
      if (sum < m) {
        m = sum;
        ans = i;
      }
    }
    printf("%d %d\n", ans, m);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  int k = 0;
  cin >> N;
  vector<int> A(N);
  for(int a = 0;a < N;a++)cin >> A[a];
  sort(A.begin(),A.end());
  cout << A[N / 2] - A[(N / 2)-1] << endl;
}

Measured memory_bytes: 3784
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    for (int i = 0; i < n - 1; ++i)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
//usr/bin/env scala $0 $@;exit

object Main{
	def judge(n:Int){
		var ma=0;var mi=1000;var s=0
		for(i <- 0 until n){
			var x=Integer.parseInt(readLine())
			if(x<mi)mi=x
			if(x>ma)ma=x
			s+=x
		}
		printf("%d\n",(s-ma-mi)/(n-2))
	}

	def main(args: Array[String]){
		while(true){
			var n=Integer.parseInt(readLine())
			if(n==0)return
			judge(n)
		}
	}
}

Measured memory_bytes: 44068
#include <stdio.h>
int m[11][11];
int main() {
	int N;
	while(1) {
		scanf("%d", &N);
		if(N == 0) break;
		int i, j;
		for(i = 0; i < N; ++ i) for(j = 0; j < N; ++ j) scanf("%d", &m[i][j]);
		for(i = 0; i < N + 1; ++ i) {
			int sum1 = 0, sum2 = 0;
			for(j = 0; j < N; ++ j) {
				sum1 += m[i][j];
				sum2 += m[j][i];
			}
			m[i][N] = sum1;
			m[N][i] = sum2;
		}
		for(i = 0; i < N + 1; ++ i) {
			for(j = 0; j < N + 1; ++ j) {
				printf("%5d", m[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

int main(){
  ll n;
  ll tmp=0;
  bool ans = true;
  cin >> n;
  vector<ll>a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(), a.end());
  rep(i,n){
    if(tmp==a[i]){
      ans = false;
      continue;
    }
    else if(tmp<a[i]){
      tmp=a[i];
    }
  }
  if(ans==true)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1792
read N
awk '{print $0,NR<='$N'?0:1}'\
	| sort -nk1\
	| awk '{a[NR,1]=$2; a[NR,2]=$3} END{
				cnt=0
				for(i=1;i<=NR;i++) {
					if(a[i,2]==1) {
						max=-1
						ind=0
						for(j=1;j<i;j++){
							if(a[j,1]!=""&&a[j,2]==0&&a[j,1]<a[i,1]&&max<a[j,1]){
								max=a[j,1]
								ind=j
							}
						}
						if(ind!=0){
							cnt++
							a[ind,1]=a[ind,2]=""
						}
					}
				}
				print cnt
			}'

Measured memory_bytes: 788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

PI lastr[50000],lastc[50000];

main(){
  int r,c,q;
  while(cin>>r>>c>>q,r){
    memset(lastr,0,sizeof(lastr));
    memset(lastc,0,sizeof(lastc));
    rep(i,q){
      int a,b,o;
      cin>>a>>b>>o;
      if(a)lastc[b]=mp(o,i+1);
      else lastr[b]=mp(o,i+1);
    }


    //rep(i,r)cout<<'('<<lastr[i].F<<','<<lastr[i].S<<") ";cout<<endl;
    //rep(i,c)cout<<'('<<lastc[i].F<<','<<lastc[i].S<<") ";cout<<endl;
    vector<int> rs,rd;
    rep(i,r){
      if(lastr[i].F)rs.pb(lastr[i].S);
      else rd.pb(lastr[i].S);
    }
    sort(ALL(rs));
    sort(ALL(rd));
    ll ans=0;
    rep(i,c){
      if(lastc[i].F){
        ans+=SZ(rs);
        if(SZ(rd) && rd[0]<lastc[i].S)
          ans+=distance(rd.begin(),lower_bound(ALL(rd),lastc[i].S));
      }else if(lastc[i].S==0){
        ans+=SZ(rs);
      }else{
        if(SZ(rs) && rs.back()>lastc[i].S){
          ans+=SZ(rs)-distance(rs.begin(),lower_bound(ALL(rs),lastc[i].S));
        }
      }
      //cout<<ans<<' ';
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
'use strict';

function main(input) {
  const args = input.split('\n');
  const strings = args.slice(1);
  const counter = new Map();
  var maxValue = 1;
  for (let string of strings) {
    if (counter.has(string)) {
      let newNumber = counter.get(string) + 1;
      counter.set(string, newNumber);
      if (newNumber > maxValue) {
        maxValue = newNumber;
      }
    } else {
      counter.set(string, 1);
    }
  }
  var ans = [];
  counter.forEach((value, key) => {
    if (value === maxValue) {
      ans.push(key);
    }
  });
  ans.sort();
  ans.forEach((ans) => {
    console.log(ans);
  });
}

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

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

using namespace std;

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

long long lcm(long long a,long long b){
  long long g = gcd(a,b);
  return a/g*b;
}

int main(void){
	long long int  a,b,c,d,e;
  cin >> a >> b >> c >> d ;
  cin >> e;
  
  
  cout << (e/2)*(min({a*8,b*4,c*2,d})) + (e%2)*(min({a*4,b*2,c})) << endl;
                                               }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
    int x=0,w=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=0,ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return w?x:-x;
}
#define pc(x) __builtin_popcount(x)
int n,A,B,all;
void dfs(int x,int y,int ban){
    if(pc(ban^all)==1){printf("%d %d ",y,x^y);return;}
    for(int i=0;i<n;++i)
        if((~ban>>i&1)&&(x>>i&1))
            for(int j=0;j<n;++j)
                if((~ban>>j&1)&&i!=j){
                    dfs(1<<j,y,ban|1<<i);
                    dfs(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),ban|1<<i);
                    return;
                }
}
int main(){
    n=gi(),A=gi(),B=gi(),all=(1<<n)-1;
    if(pc(A^B)&1)puts("YES"),dfs(A^B,A,0);
    else puts("NO");
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
	Scanner sc =new Scanner(System.in);
	int r=sc.nextInt();
	int g=sc.nextInt();
	int b=sc.nextInt();
	int k=sc.nextInt();
	while(k>0) {
		if(b<g&&b<r) {
			b=b*2;
			
		}else if(g<r) {
			g=g*2;
			
			
		}else if(r<g&&g<b) {
			b=b*2;
			
		}else if(b<g||b<r) {
			b=b*2;
			
		}else if(r==b&&b==g) {
			b=b*2;
			
		}else if(r==g) {
			g=g*2;
			
		}else if(r==b) {
			b=b*2;
		}else if(g==b) {
			b=b*2;
		}
		
		k--;
	}
	int flag=0;
	if(b>g&&g>r) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
	
	
}
}

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

const int maxn(605);
const int mod(1e9 + 7);

inline void Inc(int &x, const int y) {
    x = x + y >= mod ? x + y - mod : x + y;
}

inline void Dec(int &x, const int y) {
    x = x - y < 0 ? x - y + mod : x - y;
}

inline int Add(const int x, const int y) {
    return x + y >= mod ? x + y - mod : x + y;
}

inline int Sub(const int x, const int y) {
    return x - y < 0 ? x - y + mod : x - y;
}

inline int Pow(ll x, int y) {
    int ret = 1;
    for (; y; y >>= 1, x = x * x % mod)
        if (y & 1) ret = ret * x % mod;
    return ret;
}

int a[maxn], n, op[maxn], f[maxn][maxn][maxn], ans;

int main() {
	int i, j, k, c1, c2;
	scanf("%d", &n);
	for (i = 1, j = n << 1; i <= j; ++i) scanf("%d", &a[i]);
	for (i = 1; i <= n; ++i) {
		if (a[2 * i - 1] != -1) op[a[2 * i - 1]] = a[i << 1];
		if (a[i << 1] != -1) op[a[i << 1]] = a[2 * i - 1];
	}
	f[n * 2 + 1][0][0] = 1, c1 = 0, c2 = 0;
	for (i = n << 1; i; --i) {
		op[i] ? ++c1 : ++c2;
		if (op[i] > 0) {  memcpy(f[i], f[i + 1], sizeof(f[i])); continue;  }
		for (j = 0; j <= c1; ++j)
			for (k = 0; k <= c2; ++k)
				if (f[i + 1][j][k]) {
					if (!op[i]) {
						Inc(f[i][j][k + 1], f[i + 1][j][k]);
						if (j) Inc(f[i][j - 1][k], (ll)f[i + 1][j][k] * j % mod);
						if (k) Inc(f[i][j][k - 1], f[i + 1][j][k]);
					}
					else {
						Inc(f[i][j + 1][k], f[i + 1][j][k]);
						if (k) Inc(f[i][j][k - 1], f[i + 1][j][k]);
					}
				}
	}
	for (c2 = 0, i = 1; i <= n; ++i) c2 += a[i << 1] == -1 && a[i * 2 - 1] == -1;
	for (ans = f[1][0][0], i = 1; i <= c2; ++i) ans = (ll)ans * i % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 859008
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x < y) return x;
	return y;
}

ll get_ans(int index1, int index2, ll x, vector<ll> &s, vector<ll> &t){
	if (s[index1] - x >= 0 == t[index2] - x >= 0){
		return llmax(abs(s[index1] - x), abs(t[index2] - x));
	}else{
		return llmax(abs(s[index1] - x), abs(t[index2] - x)) + llmin(abs(s[index1] - x), abs(t[index2] - x))*2;
	}
}


int main(){
	ll a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(a);
	vector<ll> t(b);

	for (int i = 0; i < a; i++)	cin >> s[i];
	for (int i = 0; i < b; i++) cin >> t[i];

	for (int i = 0; i < q; i++){
		ll x;
		cin >> x;
		int index1 = lower_bound(s.begin(), s.end(), x) - s.begin();
		int index2 = lower_bound(t.begin(), t.end(), x) - t.begin();
		if (index1 == 0){
			if (index2 == 0){
				cout << get_ans(index1, index2, x, s, t) << endl;
			}else{
				cout << llmin(get_ans(index1, index2, x, s, t), get_ans(index1, index2-1, x, s, t)) << endl;
			}
		}else{
			if (index2 == 0){
				cout << llmin(get_ans(index1, index2, x, s, t), get_ans(index1-1, index2, x, s, t)) << endl;
			}else{
				cout << llmin(min(get_ans(index1, index2, x, s, t), get_ans(index1-1, index2, x, s, t)), llmin(get_ans(index1-1, index2-1, x, s, t), get_ans(index1, index2-1, x, s, t))) << endl;			
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);

    if(a % 2 == 0 || b % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	ll n;
	cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
	}
	map<ll, ll> ma;
	ma[-1] = 3;
	ll ans = 1;
	for (ll i = 0; i < n && ans; i++) {
		ans *= ma[ar[i] - 1];
		ans %= MOD;
		ma[ar[i] - 1]--;
		ma[ar[i]]++;
	}
	cout << ans << "\n";
}
	


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

int solve(vector<int> &a)
{
    int n = a.size();
    vector<int> dp(n);
    dp[0] = dp[1] = 0;
    dp[2] = dp[1] + abs(a[2]-a[1]);
    for(int i=3; i<=n; i++){
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
    }

    return  dp[n-1];
}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) cin >> a[i];
    cout << solve(a) << '\n';
    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int l[n],r[n];
  REP(i,n){
    if(i==0){
      l[i]=a[i];
    }else{
      l[i]=max(l[i-1],a[i]);
    }
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      r[i]=a[i];
    }else{
      r[i]=max(r[i+1],a[i]);
    }
  }
  REP(i,n){
    if(i==0){
      cout<<r[i+1]<<endl;
    }else if(i==n-1){
      cout<<l[i-1]<<endl;
    }else{
      cout<<max(l[i-1],r[i+1])<<endl;
    }
  }
  return 0;
}


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

int main(){
  double xa,ya,xb,yb,ra,rb,dis;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    dis=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    if(dis>ra+rb) cout<<"0"<<endl;
    else if(dis<ra-rb) cout<<"2"<<endl;
    else if(dis<rb-ra) cout<<"-2"<<endl;
    else cout<<"1"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.*;
import java.util.stream.LongStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();

        long max = LongStream.of(a * c,a * d,b * c, b * d)
                .max().orElse(0);

        System.out.println(max);
    }
}


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

int main() {
	int n,m; cin>>n>>m;
	int arr[n];
	for(int i =0; i<n; i++)
		cin>>arr[i];
		
	vector<int> g[n+1];
	
	for(int i=0; i<m; i++){
		int u,v; cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int rta = 0;
	
	for(int i=0; i<n; i++){
		bool flag  = true;
		for(auto&x : g[i]){
			if(g[i].size() == 0){
				break;
			}
			else if(arr[i]<=arr[x]){
				flag = false;
				break;
			}
		}
		if(flag)rta++;
	}
	cout<<rta<<endl;
}

Measured memory_bytes: 9128
#include<stdio.h>

void trace(int A[],int N){
   int i;
   for(i=0;i<N;i++){
   if(i>0)printf(" ");
   printf("%d",A[i]);
   }
   printf("\n");
}

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

int main(){
   int N,i,j;
   int A[100];

   scanf("%d",&N);
   for(i=0;i<N;i++)scanf("%d",&A[i]);

   trace(A,N);
   insertionSort(A,N);

   return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

vi a, ans;
vector<vi> g;
vi dq;

void dfs(int s, int p = 0)
{
    auto it = lb(dq, a[s]);
    bool flag = false;
    int num = 0;
    if (it == dq.end())
    {
        dq.push_back(a[s]);
    }
    else
    {
        flag = true;
        num = *it;
        *it = a[s];
    }
    ans[s] = dq.size();
    for (auto it : g[s])
        if (it != p)
            dfs(it, s);
    it=lb(dq,a[s]);
    if (flag)
        *it = num;
    else
        dq.pop_back();
}

void solve(int testCaseNumber = 1)
{
    int n;
    cin >> n;
    a = vi(n + 1);
    ans = vi(n + 1);
    g = vector<vi>(n + 1);
    rep(i, 1, n) cin >> a[i];
    rlt(i, 1, n)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    rep(i, 1, n) cnl(ans[i]);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 31624
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n;
	cin >> n;
	int x = 1;
	while(2*x <= n)x *= 2;
	cout << x << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc068.contest.atcoder.jp/tasks/abc068_b

Measured memory_bytes: 3644
import java.util.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new Q2000A();
	}
	
	class Q2000A{
		Q2000A(){
			SET = sc.nextInt();
			while(--SET>=0){
				solve();
			}
		}
		int SET,N;
		final double EPS = 0.05/100,
					EPS2 = 1.0e-10;
		void solve(){
			double[] len = new double[3];
			for(int i=0; i<3; ++i)	len[i]=sc.nextDouble();
			
			N=sc.nextInt();
			
			Point3D[] point=new Point3D[N];
			for(int i=0; i<N; ++i)	point[i]=new Point3D(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
			
			for(int p=0; p<N; ++p){
				for(int q=0; q<N; ++q){
					for(int r=0; r<N; ++r){
						double[] len2 = {	point[p].getDis(point[q]),
											point[q].getDis(point[r]),
											point[r].getDis(point[p]) };
						boolean flg=true;
						for(int i=0; i<3; ++i){
							double tmp1 = len[i]*len2[(i+1)%3],
									tmp2 = len[(i+1)%3]*len2[i];
							if(tmp1 < EPS2 || tmp2 < EPS2){
								flg=false;
								break;
							}
							if( !(max(tmp1,tmp2)/min(tmp1,tmp2) < 1.0+EPS)){
								flg = false;
								break;
							}
						}
						if(flg){
							System.out.println((r+1)+" "+(p+1)+" "+(q+1));
							return;
						}
					}
				}
			}
		}
		class Point3D{
			double x,y,z;
			Point3D(double x,double y,double z){
				this.x=x;	this.y=y;	this.z=z;
			}
			double getDis(Point3D a){
				double ret=0.0;
				double xd = a.x-x,
						yd = a.y-y,
						zd = a.z-z;
				ret = sqrt(xd*xd+yd*yd+zd*zd);
				return ret;
			}
		}
	}
}

Measured memory_bytes: 31636
#include<iostream>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
#define Maxn 205
bitset<Maxn> a[60];
bitset<Maxn> b[Maxn];
char S[Maxn];
ll A[Maxn];

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;++i)
		    for(int j=1;j<=n;++j)b[i][j]=0;
		for(int i=0;i<60;++i)
		    for(int j=1;j<=n;++j)a[i][j]=0; 
		for(int i=1;i<=n;++i){
			scanf("%lld",&A[i]);
			for(int j=0;j<60;++j)
			    if(A[i]&(1ll<<j))a[j][i]=1;
		}
		scanf("%s",S+1);
		for(int i=0;i<60;++i)
		    for(int j=n;j>=1;--j)
		        if(a[i][j]){
					if(!b[j][j]){
						b[j]=a[i];break;
					}
					else a[i]=a[i]^b[j];
		        }
		int last=n+1;
		bool flag=true;
		for(int i=n;i>=1;--i)
		    if(b[i][i]){
				if(S[i]=='1')flag=false;
		    }
	    if(flag)puts("0");
	    else puts("1");
	}
	return 0; 
}

Measured memory_bytes: 3020
/*input

*/
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <assert.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define MOD2 1000000009ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &(x))
#define slld(x) scanf("%lld", &(x))
#define ss(x) scanf("%s", x)
#define sc(x) scanf(" %c", &x)
#define pd(x) printf("%d\n", (x))
#define plld(x) printf("%lld\n", (x));
#define gc getchar

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<int, int> vii;
typedef vector<ll, ll> vll;

void scanint(int &x)
{
    register int c = gc();
    bool flag = false;
    x = 0;
    for(;((c<48 && c!=45) || c>57);c = gc());
    if(c==45)
    {
		flag = true;
		c = gc();
    }
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(flag)
    	x = x - (x<<1);
    return;
}

void scanll(ll &x)
{
	register long long c;
	bool flag = false;
	x = 0;
	for(;((c<48 && c!=45) || c>57);c = gc());
	if(c==45)
	{
		flag = true;
		c = gc();
	}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(flag)
    	x = x - (x<<1);
	return;
}

const int N = 100005;
vector<int> v[N];
int deg[N], parent[N], ans[N];
int root;

void dfs(int u)
{
	int pt;
	for(int i = 0; i<v[u].size(); i++)
	{
		pt = v[u][i];
		if(pt == parent[u])
			continue;
		if(deg[pt] != 2)
		{
			ans[pt]++;	
			return;
		}
		else
		{
			parent[pt] = u;
			dfs(pt);
		}
	}
	return;
}

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

	// clock_t clk;
	// clk = clock();
	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	
	int n, a, b;
	cin >> n;
	for(int i = 1; i<n; i++)
	{
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
		deg[a]++;
		deg[b]++;
	}
	for(int i = 0; i<n; i++)
	{
		if(deg[i] == 1) // leaf
		{
			root = i;
			parent[root] = root;
			dfs(root);
		}
	}	
	int sum = 0;
	for(int i = 0; i<n; i++)
		sum += max(0, ans[i] - 1);
	cout << max(1, sum) << "\n";

	// clk = clock() - clk;
	// cout << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	// printf("Time: %lf", ((double)clk)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>


int main(){

  int i,j,n,q,c = 0;
  long s[10026];
  long t[512];


  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(j = 0;j < q;j++) scanf("%d",&t[j]);


  for(j = 0;j < q;j++){
    for(i = 0;i < n;i++){
      if(s[i] == t[j]){
	//printf("s = %d,t = %d\n",s[i],t[j]);
	c++;
	break;
      }
    }
  }

  printf("%d\n",c);

  return 0;
}

Measured memory_bytes: 2760
use std::cmp::Ordering::*;
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, c): (usize, usize) = parse!(it, 2);
    let mut stc = vec![vec![]; c];
    for _ in 0..n {
        let (s, t, c): (usize, usize, usize) = parse!(it, 3);
        stc[c - 1].push((s, t));
    }
    let l = 100010;
    let mut starts: Vec<i64> = vec![0; l];
    let mut ends: Vec<i64> = vec![0; l];
    for i in 0..c {
        stc[i].sort();
        for j in 0..stc[i].len() {
            let (s, t) = stc[i][j];
            if j == 0 || !(j > 0 && stc[i][j - 1].1 == stc[i][j].0) {
                starts[s] += 1;
            } else {
                ends[s] -= 1;
            }
            ends[t] += 1;
        }
    }
    let mut ret = 0;
    let mut cur = 0;
    for i in 0..l {
        cur += starts[i];
        ret = std::cmp::max(ret, cur);
        cur -= ends[i];
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;

int main() {
    long long n;
    string ans;

    cin >> n;
    while (n>0) {
        --n;
        ans += 'a' + (n%26);
        n /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}


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

int main() {
    while (true) {
        int n;
        cin >> n;
        int PlayerA;
        int PlayerB;
        if (n==0) {
            break;
        }
        PlayerA=0;
        PlayerB=0;
        while (n--) {
            int scoreA;
            int scoreB;
            cin >> scoreA >> scoreB;
            if (scoreA>scoreB) {
                PlayerA+=scoreA+scoreB;
            } else if (scoreA<scoreB) {
                PlayerB+=scoreA+scoreB;
            } else {
                PlayerA+=scoreA;
                PlayerB+=scoreB;
            }
        }
        printf("%d %d\n",PlayerA,PlayerB);
    }
    return 0;
    
}

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

int main(){

  ll N;
  cin>>N;
  int A[N];
  rep(i,N)cin>>A[i];
  
  int count=0;
  rep(i,N){

    //cout<<i<<" "<<A[i]-1<<" "<<A[A[i]-1]-1<<endl;
    if(A[A[i]-1]-1==i)count++;
    
  }
   
  cout<<count/2<<endl;
  
}


Measured memory_bytes: 3944
#include <stdio.h>
int n, b, f, r, v, a[4][3][10];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		a[b - 1][f - 1][r - 1] += v;
	}
	for(int i = 0; i < 4; i++) {
		if(i) printf("####################\n");
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 10; k++) {
				printf(" %d", a[i][j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    function<ll(ll,ll)> dfs = [&](ll x, ll y) {
        dump(x, y);
        if(x < y) return 0LL;
        if(x%y == 0) return x/y;
        ll coff = (x-x/y*y+x/y)/(x/y+1);
        return dfs(x-coff*(x/y+1), y);
    };

    ll g = 0;
    REP(i, n) {
        ll val = dfs(a[i], b[i]);
        g ^= val;
        dump(a[i], b[i], val);
    }

    if(g == 0) cout << "Aoki" << endl;
    else cout << "Takahashi" << endl;

    return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string n;
    cin >> n;
    if(n[0]=='9' || n[1]=='9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}



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


struct Node {
    int id;
    int parentId;
    int leftId;
    int rightId;
};


class BinaryTree {

public:
    static const int NIL_ID = -1;
    Node *nodes;

    BinaryTree(int cnt) {
        nodes = (Node *)malloc(sizeof(Node) * cnt);
        for (int i = 0; i < cnt; i++)
        {
            nodes[i] = Node{i, NIL_ID, NIL_ID, NIL_ID};
        }
    }

    ~BinaryTree() {
        delete nodes;
    }

    void push_values(int id, int leftId, int rightId) {
        nodes[id].leftId = leftId;
        nodes[id].rightId = rightId;

        if (leftId != NIL_ID)
            nodes[leftId].parentId = id;
        if (rightId != NIL_ID)
            nodes[rightId].parentId = id;
    }

    int getSibling(int id) {
        Node node = nodes[id];

        int parentId = node.parentId;
        if (parentId == NIL_ID)
            return NIL_ID;
        
        Node parent = nodes[parentId];

        if (parent.leftId == id) {
            return parent.rightId;
        } else {
            return parent.leftId;
        }    
    }

    int getDegree(int id) {
        Node node = nodes[id];

        int degree = 0;
        
        if (node.leftId != NIL_ID)
            degree++;
        if (node.rightId != NIL_ID)
            degree++;

        return degree;
    }

    int getDepth(int id) {
        Node node = nodes[id];
        int depth = 0;

        while(node.parentId != NIL_ID) {
            node = nodes[node.parentId];
            depth++;
        }

        return depth;
    }

    int getHeight(int id) {
        int h1 = 0, h2 = 0;
        Node node = nodes[id];

        if (node.rightId != NIL_ID)
            h1 = getHeight(node.rightId) + 1;
        if (node.leftId != NIL_ID)
            h2 = getHeight(node.leftId) + 1;

        return max(h1, h2);
    }

    string getType(int id) {
        Node node = nodes[id];

        if (node.parentId == NIL_ID)
            return "root";
        
        if (getDegree(id) > 0) {
            return "internal node";
        } else {
            return "leaf";
        }
    }

    void printNode(int id) {
        Node node = nodes[id];
        cout << "node " << id << ": parent = " << node.parentId << ", sibling = ";
        cout << getSibling(id) << ", degree = " << getDegree(id) << ", depth = ";
        cout << getDepth(id) << ", height = " << getHeight(id) << ", " << getType(id);
    }
};


int main() {
    int N;
    int i, id, leftId, rightId;

    cin >> N;

    BinaryTree tree = BinaryTree(N);

    for (i = 0; i < N; i++) {
        cin >> id >> leftId >> rightId;
        tree.push_values(id, leftId, rightId);
    }

    for (i = 0; i < N; i++) {
        tree.printNode(i);
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3208
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int length = int.Parse(Console.ReadLine());
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            string[] str3 = Console.ReadLine().Split(' ');
            int[] numbers1 = new int[str1.Length];
            int[] numbers2 = new int[str2.Length];
            int[] numbers3 = new int[str3.Length];

            for (int i = 0; i < length; i++)
            {
                numbers1[i] = int.Parse(str1[i]);
            }

            for (int i = 0; i < length; i++)
            {
                numbers2[i] = int.Parse(str2[i]);
            }

            for (int i = 0; i < numbers3.Length; i++)
            {
                numbers3[i] = int.Parse(str3[i]);
            }

            int sum = 0;
            int pre = 0;
            int now = 0;

            for (int i = 0; i < length; i++)
            {
                sum += numbers2[i];
                
                if (i > 0)
                {
                    pre = numbers1[i - 1];
                    now = numbers1[i];

                    if (now - pre == 1)
                    {
                        sum += numbers3[pre - 1];
                    }
                }
            }

            Console.WriteLine($"{sum}");
        }
    }
}


Measured memory_bytes: 13140
L,R = map(int,input().split())
l = L%2019
r = R%2019
Min_Answer = 2018

if L//2019 == R//2019:
    for i in range(l,r+1):
        for j in range (i,r+1):
            if i ==j :
                continue
            Answer = (i*j) % 2019
            Min_Answer = min(Answer,Min_Answer)

else:
 Min_Answer = 0

print(Min_Answer)


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string s;
    cin >> s;

    if(s.size() == 3) {
        reverse(all(s));
    }

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;;

int c[100][100],w,h;

void dfs(int a, int b) {
	c[a][b] = 0;
	for (int k = -1; k <= 1; k++) {
		for (int l = -1; l <= 1; l++) {
				if (a + k >= 0 && a + k < h&&b + l >= 0 && b + l < w) {
					if (c[a + k][b + l] == 1){
					dfs(a + k, b + l);
				}
			}
		}
	}
	return;
}

int main() {
	while (1) {
		int ans = 0;
		cin >> w >> h;
		if (w == 0 && h == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (c[i][j] == 1) {
					dfs(i, j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
my @input = split(/ /, <STDIN>);
my @cookies;
push(@cookies, $input[0]);
push(@cookies, $input[1]);
push(@cookies, $input[0] + $input[1]);

for my $cookie (@cookies) {
    if (($cookie % 3) == 0) {
        print "Possible";
        exit(0);
    }
}
print "Impossible";

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    set<string> st;

    rep(i,n){
        string s; cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;
}

Measured memory_bytes: 19136
///At Coder  : Frog 1
///Approach  : Recursive DP
///Complexity:

#include<bits/stdc++.h>
using namespace std;

int dp[100005];
int arr[100005];

int frog(int pos, int n){

    if(pos==n)return 0;
    if(dp[pos]!=-1)return dp[pos];

    int a=0,b=INT_MAX;
    if(pos+1<=n)
        a=abs(arr[pos]-arr[pos+1])+frog(pos+1,n);
    if(pos+2<=n)
        b=abs(arr[pos]-arr[pos+2])+frog(pos+2,n);

    return dp[pos]=min(a,b);
}

int main(){

    ios_base::sync_with_stdio(false);cout.tie(false);cin.tie(false);

    int n,i;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>arr[i];
        dp[i]=-1;
    }
    cout<<frog(1,n)<<endl;


    return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1e9 + 7)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char s; cin >> s;
  cout << (char)(s + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define MAX_N 20001
#define MAX_Y 256

int N, M;
vector<int> C, X;
int dp[MAX_Y][MAX_N];
bool vis[MAX_Y][MAX_N];

int solve(int y, int n)
{
    if (vis[y][n])
        return dp[y][n];
    vis[y][n] = true;
    if (n == N)
        return dp[y][n] = 0;
    int res = INF;
    rep(i, M)
    {
        int nxt = y + C[i];
        nxt = max(nxt, 0LL);
        nxt = min(nxt, 255LL);
        int d = nxt - X[n];
        res = min(res, solve(nxt, n + 1) + d * d);
    }
    return dp[y][n] = res;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    while (1)
    {
        cin >> N >> M;
        if (N == 0)
            break;
        C.resize(M);
        rep(i, M) cin >> C[i];
        X.resize(N);
        rep(i, N) cin >> X[i];
        rep(i, MAX_Y) rep(j, MAX_N) vis[i][j] = false;
        cout << solve(128, 0) << endl;
    }
}


Measured memory_bytes: 49592
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int num[100000];
int N;
int tempnum;
long long ans;
long long tempsub;
long long tempbes;
long long sumn;
long long sump;
bool flagn=false;
bool flagp=false;
int minp1;
int minp2;
int maxn1;
int maxn2;
int loc;
long long getans()
{
	long long temp;
	if(flagn==false&&flagp==true)
	{
		temp=sump-2*minp1;
	}
	else if(flagn==true&&flagp==false)
	{
		temp=sumn+2*maxn1;
	}
	else
	{
		temp=sumn+sump;
	}
	return temp;
}
int main()
{
	loc=1000000;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>tempnum;
		num[i]=tempnum;
		if(tempnum<0)
		{
			flagn=true;
			sumn+=num[i];
		}
		if(tempnum>=0)
		{
			flagp=true;
			sump+=num[i];
		}
	}
	sort(num,num+N);
	for(int i=0;i<N;i++)
	{
		if(num[i]>=0)
		{
			loc=i;
			break;
		}
	}
	sumn=-sumn;
	if(N==2)
	{
		cout<<num[1]-num[0]<<endl;
		cout<<num[1]<<" "<<num[0]<<endl;
		return 0;
	}
	if(flagn==false&&flagp==true)
	{
		minp1=num[loc];
		minp2=num[loc+1];
		ans=getans();
		cout<<ans<<endl;
		cout<<minp1<<" "<<minp2<<endl;
		tempsub=minp1-minp2;
		for(int i=2;i<N-1;i++)
		{
			cout<<tempsub<<" "<<num[i]<<endl;
			tempsub-=num[i];
		}
		cout<<num[N-1]<<" "<<tempsub<<endl;
	}
	else if(flagn==true&&flagp==false)
	{
		maxn1=num[N-1];
		maxn2=num[N-2];
		ans=getans();
		cout<<ans<<endl;
		cout<<maxn1<<" "<<maxn2<<endl;
		tempsub=maxn1-maxn2;
		for(int i=N-3;i>=0;i--)
		{
			cout<<tempsub<<" "<<num[i]<<endl;
			tempsub-=num[i];
		}
	}
	else
	{
		maxn1=num[loc-1];
		ans=getans();
		cout<<ans<<endl;
		tempsub=maxn1;
		for(int i=loc;i<N-1;i++)
		{
			cout<<tempsub<<" "<<num[i]<<endl;
			tempsub-=num[i];
		}
		tempbes=tempsub;
		tempsub=num[N-1];
		cout<<tempsub<<" "<<tempbes<<endl;
		tempsub-=tempbes;
		for(int i=loc-2;i>=0;i--)
		{
			cout<<tempsub<<" "<<num[i]<<endl;
			tempsub-=num[i];
		}
	}
	return 0;
}

Measured memory_bytes: 2304
// 2644 Longest Match
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2644
// by Equim on 16-12-20

using System;

class Program
{
    public static int Process(ref string S)
    {
        string[] Raw = Console.ReadLine().Split(' ');
        string x = Raw[0];
        string y = Raw[1];

        int BeginAt = S.IndexOf(x);
        if (BeginAt == -1) return 0;

        int EndAt = S.LastIndexOf(y);
        if (EndAt == -1 || EndAt < BeginAt) return 0;

        int RejudgePoint = x.LastIndexOf(y);
        if (EndAt - BeginAt < x.Length && RejudgePoint != -1 && RejudgePoint != x.Length - y.Length) return 0;

        return EndAt - BeginAt + y.Length;
    }

    public static void Main(string[] args)
    {
        string S = Console.ReadLine();
        int Cases = int.Parse(Console.ReadLine());

        for (int t = 1; t <= Cases; t++)
            Console.WriteLine(Process(ref S));
    }
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	int mx=-1<<28, ans =0;
	rep(i,n){
		int p; cin>>p;
		mx = max(mx, p);
		ans +=p;
	}
	ans -= mx/2;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main() {

	string w;
	char charcheck[26]={};
	int check[26]={};
	int tmp=0;
	
	cin >> w;
	
	for(int i=0;w[i]!=0;i++){
		
		for(int j=0;j<=tmp;j++){
			if(w[i]==charcheck[j]){
				check[j]++;
				break;
			}
			else if(j==tmp) {
				tmp++;
				charcheck[tmp]=w[i];
			}
		}
	}
	
	for(int i=0;i<=tmp;i++){
		if(check[i]%2!=0){
			cout << "No" << endl;
			break;
			}
		else if(i==tmp) cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256