akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <map> 
using namespace std;
typedef long long ll;


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


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))


# 解説
# 違うbitの数が奇数なら戻ってこれる


def bitcount(n):
    ret = 0
    while n > 0:
        ret += n & 1
        n >>= 1
    return ret


# vs = []
# for i in range(1 << N):
#     for j in range(i, 1 << N):
#         if bitcount(i ^ j) == 1:
#             vs.append((i, j))
# plot_graph(vs)


# @lru_cache(maxsize=None)
# @debug
def solve(n, a, b):
    if n <= 0:
        return []
    if bitcount(a ^ b) % 2 == 0:
        return []
    if n == 1:
        return [a, b]
    # 奇数
    # 違うbitを1つ取り除く
    mask = 1
    while (a ^ b) & mask == 0:
        mask <<= 1
    r_mask = mask - 1
    l_mask = ~mask - r_mask
    na = ((a & l_mask) >> 1) + (a & r_mask)
    nb = ((b & l_mask) >> 1) + (b & r_mask)
    mid = na ^ 1
    ret = []
    for r in solve(n - 1, na, mid):
        ret.append(((r << 1) & l_mask) + (a & mask) + (r & r_mask))
    for r in solve(n - 1, mid, nb):
        ret.append(((r << 1) & l_mask) + (b & mask) + (r & r_mask))
    return ret


ans = solve(N, A, B)
if ans:
    print('YES')
    print(*ans)
else:
    print('NO')

# for A in range(1 << N):
#     for B in range(1 << N):
#         ans = solve(N, A, B)
#         if ans:
#             assert ans[0] == A
#             assert ans[-1] == B
#             for a, b in zip(ans, ans[1:]):
#                 assert bitcount(a ^ b) == 1
#                 assert a < (1 << N)


Measured memory_bytes: 13332
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string s;
  int a_n,z_n;
  //vector<char> vc;
  cin >> s;
  for(int i=0;i<s.length();i++){
 // vc.push_back(s[i]);

  if(s[i]=='A'){
    a_n=i;
    break;
    }
  }
  for(int i=a_n+1;i<s.length();i++){
   if(s[i]=='Z'){
    z_n=i;
  }
}
  cout << (z_n+ 1- a_n);
  return 0;
}

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


int main()
{
	int N;
	cin>>N;
	map<string,ll> dict;
	rep(i,N)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		dict[s]++;
	}
	ll ans=0;
	for(pair<string,ll> p : dict)
	{
		ans+=(p.second)*(p.second-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

string genstr(string& s){
	string ans="";
	rp(i,s){
		if('A'<=s[i] && s[i]<='z'){
			ans+=s[i]-('a'-'A');
		}else{
			ans+=s[i];
		}
	}
	return ans;
}
int main()
{
	string n;
	getline(cin,n);
	cout << genstr(n) << endl;
}

Measured memory_bytes: 1184
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

template <class T>
struct ModInt {
    T x;
    ModInt(T x = 0) : x((x + mod) % mod) {}
    ModInt &operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt a) const {
        ModInt res(*this);
        return res /= a;
    }
};
using mint = ModInt<long long>;

string s;
ll cnt[3000];
void solve() {
    cin >> s;
    mod = 2019;
    mint now = 0;
    mint p = 1;
    ++cnt[0];
    repd(i, sz(s)) {
        int val = s[i] - '0';
        now += mint(val) * p;
        p *= 10;
        ++cnt[now.x];
    }

    ll ans = 0;
    rep(i, 2021) ans += cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << endl;
}

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


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin >>n;	
	if (n==1) cout << "Hello World\n" << endl;
	else {
	int a,b; cin>>a>>b;
	cout << (a+b) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 305;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int a[N] , b[N];
int c[N] , d[N];
vector <int> g[N];
bool used[N];
int mt[N];

bool dfs(int v){
    if(used[v] == true)return false;
    used[v] = true;
    for(int i=0;i<(int)g[v].size();i++){
        int to = g[v][i];
        if(mt[to] == -1 || dfs(mt[to])){
            mt[to] = v;
            return true;
        }
    }
    return false;
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d%d",&c[i],&d[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(a[i] < c[j] && b[i] < d[j]){
                g[i].push_back(j + n);
            }
        }
    }
    for(int i=1;i<=n;i++){
        used[i] = false;
        mt[i + n] = -1;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            used[j] = false;
        }
        dfs(i);
    }
    int answ = 0;
    for(int i=1;i<=n;i++){
        if(mt[i + n] != -1){
            answ++;
        }
    }
    cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;

  if(a>b) swap(a,b);

  vi resa,resb;
  for(int i=1;i*i<=a;i++){
    if(a%i==0){
      resa.PB(i);
      if(i*i!=a) resa.PB(a/i);
    }
  }


  for(int i=1;i*i<=b;i++){
    if(b%i==0){
      resb.PB(i);
      if(i*i!=b) resb.PB(b/i);
    }
  }

    vi res;
  sort(all(resa));
  sort(all(resb));

  for(int x:resa){
    for(int y:resb){
      //cout<<x<<' '<<y<<endl;
      if(x==y) res.PB(x);
    }
  }

    vi ans;
  for(int x:res){
    bool flag=true;
    for(int y:ans){
      if(__gcd(x,y)!=1) flag=false;
    }
    if(flag) ans.PB(x);
  }

  cout<<ans.size()<<endl;
  

}

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


int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	std::map<std::string, int> s;
	for (int i = 0; i < n; i++) {
		std::string tmp;
		std::cin >> tmp;
		std::sort(tmp.begin(), tmp.end());
		s[tmp]++;
	}
	int64_t res = 0;
	for (auto &i : s) res += (int64_t) i.second * (i.second - 1) / 2;
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int N, W;
int dp[101][303];

int main() {
  cin >> N >> W;
  vector<int> w(N);
  vector<int> v(N);
  cin >> w.at(0) >> v.at(0);
  int base = w.at(0);
  w.at(0) = 0;

  rep(i, N-1) {
    int wnow, vnow;
    cin >> wnow >> vnow;
    w.at(i+1) = wnow - base;
    v.at(i+1) = vnow;
  }

  rep(i, 101) {
    rep(j, 303) {
      dp[i][j] = -1;
    }
  }

  dp[0][0] = 0;
  rep(k, N) {
    for (int i=k+1; i>0; i--) {
      for (int j = 3 * N; j >= w.at(k); j--) {
        if (dp[i-1][j-w.at(k)] != -1) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - w.at(k)] + v.at(k));
        }
      }
    }
  }
  int ans = 0;
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=3*N; j++) {
      if ((ll)i*base+j<=W) {
        ans = max(dp[i][j], ans);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, h;
	cin >> n >> h;
	int mx = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		mx = max(mx, a[i]);
	}
	vector<int> thr;
	for (int i = 1; i <= n; ++i) {
		if (b[i] > mx) {
			thr.push_back(b[i]);
		}
	}
	sort(thr.begin(), thr.end());
	int answer = 0;
	while (h > 0 and thr.empty() == false) {
		++answer;
		h -= thr.back();
		thr.pop_back();
	}
	if (h <= 0) {
		cout << answer;
		return 0;
	}
	answer += ceil(1.0 * h / mx);
	cout << answer;
}

Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            //var watch = new Stopwatch();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);


            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = p[0];
            int K = p[1];


            //watch.Start();

            decimal ans = 0;
            for(var i = 1; i <= N; i++)
            {
                int P = i;
                decimal r = 1;
                while (P < K)
                {
                    r /= 2;
                    P *= 2;
                }
                ans += r;
            }

            ans /= N;

            Console.WriteLine(ans);

            //Console.Out.Flush();
            /*watch.Stop();

            Console.WriteLine($"time:{watch.ElapsedMilliseconds} ms"); //Debug Only.
            Console.Out.Flush();*/
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13396
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, l = MI()
    ans = 0
    temp = l
    for i in range(n):
        ans += l+i
        if abs(temp) > abs(l+i):
            temp = l+i
        
    ans -= temp
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9104
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<ll> a(n, 0), b(n, 0), c(n, 0);
    ll bsum = 0;

    REP(i, n) {
        cin >> a[i] >> b[i];
        c[i] = a[i] + b[i];
        bsum += b[i];
    }

    sort(ALL_OF(c), greater<ll>());

    ll ans = -bsum;
    for (int i = 0; i < n; i += 2) {
        ans += c[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  vector<ll> kouho(5);
  
  x = abs(x);
  ll memo = x / d;
  if(k <= memo){
    cout << x - d * k << endl;
    return 0;
  }
  kouho[0] = x - memo * d;
  kouho[1] = x - (memo - 1) * d;
  kouho[2] = x - (memo - 2) * d;
  kouho[3] = (memo + 1) * d - x;
  kouho[4] = (memo + 2) * d - x;
  ll res = 0;
  res = pow(10,18);
  if((k + memo) % 2 == 0){
    if(k >= memo)res = min(res,abs(kouho[0]));
    if(k >= memo + 2)res = min(res,abs(kouho[4]));
    if(k >= memo - 2)res = min(res,abs(kouho[2]));
  }
  else{
    if(k >= memo - 1)res = min(res,abs(kouho[1]));
    if(k >= memo + 1)res = min(res,abs(kouho[3]));
  }
  cout << res << endl;
  
  //cout << kouho[0] << " " << kouho[2] << " " << kouho[4] << endl;
  /*if(k % 2 == 0){
    ll a,b;
    ll memo = x / d;
    if(memo % 2 == 1){
      a = (memo + 1) * d - x;
      b = x - (memo - 1) * d;
    }
    else{
      
    }
  }*/
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll s, k;
	cin >> k >> s;
	ll ans = 0;
	for(ll i=0; i<=k; i++){
		for(ll j=0; j<=k; j++){
			if(s - (i+j) <= k and s - (i+j) >= 0)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3580
import java.util.*


fun main(args: Array<String>) {
    var sc = Scanner(System.`in`);
    var a = sc.nextInt();
    var b = sc.nextInt();
    var c = sc.nextInt();
    if (a == b && b == c && c == a) {
        println("No")
    } else if (a != b && b != c && c != a) {
        println("No")
    } else {
        println("Yes")
    }
}


Measured memory_bytes: 31012
#include<stdio.h>
int main(){
int a[100][100],b[100][100],i,j,k,n,m,l,x;
long long int c[100][100]={0};
scanf("%d%d%d",&n,&m,&l);

for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&x);
a[i][j]=x;
}
}


for(j=0;j<m;j++){
for(k=0;k<l;k++){
scanf("%d",&x);
b[j][k]=x;
}
}

for(i=0;i<n;i++){
for(k=0;k<l;k++){
for(j=0;j<m;j++){
c[i][k]+=a[i][j]*b[j][k];
}
}
}

for(i=0;i<n;i++){
for(k=0;k<l;k++){
printf("%lld",c[i][k]);
if(k!=l-1)printf(" ");
}
printf("\n");
}

return 0;
}


Measured memory_bytes: 2100
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}

const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int L = 128;
int n;
string chs;
int cnt[62];
int query(string s)
{
	printf("? %s\n", s.c_str());
	fflush(stdout);
	int x;
	scanf("%d", &x);
	return x;
}
string merge_query(string s, string t)
{
	int i = 0, j = 0;
	string ans;
	while (i<s.size()&&j<t.size())
	{
		string S = s.substr(0, i+1)+t.substr(j);
		if (query(S)==n-S.size())
		{
			ans.PB(s[i]);
			i++;
		}
		else
		{
			ans.PB(t[j]);
			j++;
		}
	}
	while (i<s.size()) ans.PB(s[i++]);
	while (j<t.size()) ans.PB(t[j++]);
	return ans;
}
int main()
{
	for (int i=0; i<26; i++) chs.PB('a'+i);
	for (int i=0; i<26; i++) chs.PB('A'+i);
	for (int i=0; i<10; i++) chs.PB('0'+i);
	
	for (int i=0; i<62; i++)
	{
		string s;
		for (int j=0; j<L; j++) s.PB(chs[i]);
		cnt[i] = L-query(s);
	}
	
/*
	cnt[0] = 1;
	cnt[1] = 1;
	cnt[2] = 1;
*/
	for (int i=0; i<62; i++) n += cnt[i];
	priority_queue<pair<int,string> > pq;
	for (int i=0; i<62; i++)
	{
		string s(cnt[i], chs[i]);
		pq.push(MP(-int(s.size()), s));
	}
	while (pq.size()>1)
	{
		auto x = pq.top(); pq.pop();
		auto y = pq.top(); pq.pop();
		pq.push(MP(x.FF+y.FF, merge_query(x.SS, y.SS)));
	}
	printf("! %s\n", pq.top().SS.c_str());
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3812
#include <cstdio>
#include <map>
#define INF 2000000000
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;
const int MAX_N = 1 << 21;

int n, q;
P dat[2*MAX_N-1];

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;
	for(int i = 0; i < 2*n-1; i++){
		dat[i].fi = i-n+1;
		dat[i].sec = -1*INF;
	}
}

void update(int k, int a){
	k += n-1;
	if(dat[k].sec == -1*INF) dat[k].sec = a;
	else dat[k].sec += a;
	while(k > 0){
		k = (k-1)/2;
		if(dat[k*2+1].sec > dat[k*2+2].sec){
			dat[k].fi = dat[k*2+1].fi;
			dat[k].sec = dat[k*2+1].sec;
		} else{
			if(dat[k*2+1].sec == dat[k*2+2].sec){
				if(dat[k*2+1].fi < dat[k*2+2].fi){
					dat[k].fi = dat[k*2+1].fi;
					dat[k].sec = dat[k*2+1].sec;
				} else{
					dat[k].fi = dat[k*2+2].fi;
					dat[k].sec = dat[k*2+2].sec;
				}
			} else{
				dat[k].fi = dat[k*2+2].fi;
				dat[k].sec = dat[k*2+2].sec;
			}
		}
	}
}

P query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return P(-1*INF,-1*INF);
	if(a <= l && r <= b) return dat[k];
	else{
		P vl = query(a,b,k*2+1,l,(l+r)/2);
		P vr = query(a,b,k*2+2,(l+r)/2,r);
		if(vl.sec > vr.sec){
			return vl;
		} else{
			if(vl.sec == vr.sec){
				if(vl.fi > vr.fi) return vr;
				else return vl;
			} else return vr;
		}
	}
}

int main(){
	scanf("%d%d", &n, &q);
	init(n);
	for(int i = 0; i < q; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		update(a,b);
		P out = query(0,n,0,0,n);
		printf("%d %d\n", out.fi+1, out.sec);
	}
}

Measured memory_bytes: 33796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    vector<ll> a(n);
    rep(i, n) {
        string s;
        cin >> s >> a[i];
        mp[s] = i;
    }
    string s;
    cin >> s;
    ll ans = 0LL;
    REP(i, mp[s]+1, n) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
lst = []
cnt = 0
if S[0] == '<':
    flg = 0
else:
    flg = 1
for i in range(len(S)):
    if flg == 0:
        if S[i] == '<':
            cnt += 1
        elif S[i] == '>':
            lst.append(['<',cnt])
            cnt = 1
            flg = 1
    elif flg == 1:
        if S[i] == '<':
            lst.append(['>', cnt])
            cnt = 1
            flg = 0
        elif S[i] == '>':
            cnt += 1
if flg == 0:
    lst.append(['<',cnt])
else:
    lst.append(['>', cnt])
#print(lst)

ans = 0
for i in range(1,len(lst)):
    if lst[i-1][0] == '<' and lst[i][0] == '>':
       n = max(lst[i-1][1],lst[i][1])
       n2 = min(lst[i-1][1],lst[i][1])
       ans += n * (n+1) /2
       ans += (n2-1)*n2 / 2

if lst[0][0] == '>':
    n3 = lst[0][1]
    ans += n3 * (n3 + 1) / 2
if lst[-1][0] == '<':
    n4 = lst[-1][1]
    ans += n4 * (n4+1) /2
print(int(ans))

Measured memory_bytes: 31552
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin>>s;
  	int st=s.size();
  	int ans=0;
  	int flag=0;
  	int te=0;
  	for(int i=0;i<st;i++){
    	if(s[i]=='R'&&!flag){
            flag=1;
            te++;
            ans=max(te,ans);
        }else if(s[i]=='R'){
            te++;
            ans=max(te,ans);
        }else {
            flag=0;
            te=0;
        }
    }
    cout<<ans;
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b == 15) cout << '+' << endl;
    else if(a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
    return 0;
}

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

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){
  for(int u : to[v]){
    if(u==p)continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 23424
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println((n*a < b) ? n*a : b);
	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <vector>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;
typedef complex<double> P;
typedef vector<P> Poly;
typedef pair<P,P> L;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

double dot(P a, P b){return a.X*b.X + a.Y*b.Y;}

double cross(P a, P b){return a.X*b.Y - a.Y*b.X;}

int ccw(P a, P b, P c){
  b -= a;c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(c) - norm(b) > EPS) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}


P intersection(L a, L b){
  //テァツ崢エテァツキツ啾テ」ツ?ィテァツ崢エテァツキツ喘テ」ツ?ョテ、ツコツ、テァツつケ
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

int in_poly(P a, Poly p){
  int n = p.size(), c = 0;
  for(int i = 0; i < n; ++i){
    P s = p[i]-a, t = p[(i+1)%n]-a;
    if(!ccw(s,t,P(0,0))) return 1;//ティツセツコテ、ツクツ?
    if(s.Y > t.Y + EPS) swap(s,t);
    if((s.Y*t.Y < 0 || (s.Y*t.Y < EPS && t.Y > EPS)) && cross(s,t) < EPS) ++c;
  }
  if(c%2) return 2;//テ・ツ??ゥツδィ
  return 0;//テ・ツ、ツ姪ゥツδィ
}


int main(){
  int N;
  map<int, int> M_x, M_y;
  while(cin >> N, N){
    double x, y;
    Poly W;
    for(int i = 0; i < N; ++i){
      cin >> x >> y;
      W.push_back(P(x,y));
      M_x[(int)x] = 0;
      M_y[(int)y] = 0;
    }
    Poly C;
    for(int i = 0; i < 4; ++i){
      cin >> x >> y;
      C.push_back(P(x,y));
      M_x[(int)x] = 0;
      M_y[(int)y] = 0;
    }
    int k = 0;
    vector<int> V_x;
    for(auto p: M_x){
      p.second = k++;
      V_x.push_back(p.first);
    }
    k = 0;
    vector<int> V_y;
    for(auto p: M_y){
      p.second = k++;
      V_y.push_back(p.first);
    }
    int n_x = V_x.size(), n_y = V_y.size();
    long long int ans = 0LL;
    for(int i = 1; i < n_x; ++i){
      for(int j = 1; j < n_y; ++j){
	P p = P((double)(V_x[i]+V_x[i-1])/2.0, (double)(V_y[j]+V_y[j-1])/2.0);
	if(in_poly(p,W) && !in_poly(p,C)) ans += (V_x[i]-V_x[i-1])*(V_y[j]-V_y[j-1]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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


int main(){
  char s[1100],t[1100];
  scanf("%s %s", s,t);
  int ans = 100000,k;
  for(size_t i = 0; i <= strlen(s) - strlen(t); i++){
    k = 0;
    for(size_t j = 0; j < strlen(t); j++){
      if(s[i+j] != t[j]){
        k++;
      }
    }
    if(k < ans){
      ans = k;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1716
function Main(input) {
  const lines = input.split('\n');
  const S = lines[0].split('');
  const T = lines[1].split('');
  let min = 10000;
  S.forEach((_, i) => {
    if (i + T.length <= S.length) {
      let count = 0;
      let pos = 0;
      while (true) {
        if (S[i + pos] !== T[pos]) count = count + 1;
        if (pos === T.length - 1) break;
        pos = pos + 1;
      }
      // console.log(S.slice(i, i + T.length));
      // console.log(T);
      // console.log(count);
      if (count < min) min = count; 
    }
  });
  console.log(min);
}

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


Measured memory_bytes: 32452
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    string N;  cin >> N;
    ll sum = 0;
    for(int i = 0 ; i < N.length() ; i++)
      sum += (N[i] - '0');

    if(sum % 9 == 0)  cout << "Yes" << endl;
    else              cout << "No"  << endl;

	return 0;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[2][310][310];

int main() {
  ll n;
  cin>>n;
  vector<string> vs;
  rep(i,0,n){
    string s;
    cin>>s;
    vs.pb(s);
  }
  rep(y,0,n){
    rep(x,0,n){
      d[0][y][x] = vs[y][x]-'a';
    }
  }
  ll ans = 0;
  ll now = 0;
  ll nex = 1;
  rep(i,0,n){
    ll flag = 1;
    rep(y,0,n){
      rep(x,y+1,n){
        if(d[now][y][x]!=d[now][x][y])flag = 0;
      }
    }
    if(flag == 1)ans += n;
    rep(y,0,n){
      rep(x,0,n){
        d[nex][y][x] = d[now][y][(x+1)%n];
      }
    }
    now = 1-now;
    nex = 1-nex;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


int solveC() {
	long long L, R;
	cin >> L >> R;
	if (L % 2019 == 0 || R % 2019 == 0 || R - L >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2018 * 2018;
	for (long long i = L; i < R; i++) {
		for (long long j = i + 1; j <= R; j++) {
			auto a = (i % 2019)*(j % 2019) % 2019;
			if (ans > a) {
				ans = a;
				//				cout << i << "*" << j << "=" << (i*j) % 2019 << "(mod 2019)" << endl;
				//				auto dummy = '-';	cin >> dummy;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


int solveD() {
	int N; cin >> N;
	long long min_a = 1000000000;
	auto As = vector<long long>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> As[i];
		min_a = min(min_a, As[i]);
	}
	auto answer = vector<long long>(N);
	for (size_t i = 0; i <= min_a * 2; i += 2) {
		answer[0] = i;
		for (size_t j = 1; j < N; j++) {
			answer[j] = As[j - 1] * 2 - answer[j - 1];
		}
		if (answer[0] + answer[N - 1] == 2 * As[N - 1])break;
	}
	for (size_t i = 0; i < N; i++) {
		cout << answer[i] << (i == N - 1 ? "\n" : " ");
	}
	return 0;
}

int main() {
	solveC();
}


Measured memory_bytes: 384
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))
T = input()
hand = []
score = 0

for i in range(N):
  if i<=K-1:
    if T[i]=="r":
      score+=P
      hand.append("p")
    elif T[i]=="s":
      score+=R
      hand.append("r")
    else:
      score+=S
      hand.append("s")
  elif i<=N-K-1:
    if T[i]=="r":
      if hand[i-K]=="p":
        if T[i+K]=="r":
          hand.append("r")
        elif T[i+K]=="s":
          hand.append("s")
        elif T[i+K]=="p":
          hand.append("r")
      else:
        score+=P
        hand.append("p")
    if T[i]=="s":
      if hand[i-K]=="r":
        if T[i+K]=="r":
          hand.append("s")
        elif T[i+K]=="s":
          hand.append("s")
        elif T[i+K]=="p":
          hand.append("p")
      else:
        score+=R
        hand.append("r")
    if T[i]=="p":
      if hand[i-K]=="s":
        if T[i+K]=="r":
          hand.append("r")
        elif T[i+K]=="s":
          hand.append("p")
        elif T[i+K]=="p":
          hand.append("p")
      else:
        score+=S
        hand.append("s")
  else:
    if T[i]=="r" and hand[i-K]!="p":
      score+=P
    if T[i]=="s" and hand[i-K]!="r":
      score+=R
    if T[i]=="p" and hand[i-K]!="s":
      score+=S

print(score)

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	string s;
	cin>>s;
	int n=s.length();
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=s[i]-'0';
	}
	if(ans%9==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3720
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  
  int xma=x;
  int a;
  rep(i,n){
    cin>>a;
    xma=max(xma,a);
  }
  int ymi=y;
  rep(i,n){
    cin>>a;
    ymi=min(ymi,a);
  }
  if(xma<ymi) cout<<"No War"<<endl;
  else cout<<"War"<<endl;

  return 0;
}

Measured memory_bytes: 3604
s = [int(c) for c in list(input())]
num = 753
ans = num
for i in range(len(s) - 2):
    x = s[i] * 10 ** 2 + s[i + 1] * 10 + s[i + 2]
    ans = min(ans, abs(num - x))
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>

using namespace std;


int main(){
	int temp, i, j, teams, total,number;
	vector<int> name;
	vector<int> time;
	time.insert(time.begin(), 99999);
	

	while (1){
		cin >> teams;
		
		if (teams == 0){
			break;
		}
		
		for (i = 0; i < teams; i++){
			cin >> number;
			total = 0;
			for (j = 0; j < 4; j++){
				cin >> temp;
				total += temp * 60;
				cin >> temp;
				total += temp;
			}

			for (j = 0; j <= i; j++){
				if (total < time[j]){
					name.insert(name.begin()+j, number);
					time.insert(time.begin()+j, total);
					break;
				}
				
			}

		}
		
		cout << name[0] << endl << name[1] << endl << name[i-2] << endl;


		//for (j = 0; j < i; j++){
		//	cout << name[j] << endl;
		//}


		name.clear();
		time.clear();
		time.insert(time.begin(),99999);
	}
}

Measured memory_bytes: 1300
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define M 200001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
deque<int> que;
bool vis[N];
int n,m;
int cnt,head[N],nxt[M],to[M];
int main()
{
	re(n),re(m);
	for(int u,v,i=1;i<=m;++i)
	{
		re(u),re(v);
		add_edge(u,v);
		add_edge(v,u);
	}

	int u=1;
	while(1)
	{
		vis[u]=1;
		que.push_back(u);
		int v=0;
		for(int i=head[u];i;i=nxt[i])
			if(!vis[to[i]])
			{
				v=to[i];
				break;
			}
		if(!v)break;
		u=v;
	}
	u=1;
	while(1)
	{
		vis[u]=1;
		int v=0;
		for(int i=head[u];i;i=nxt[i])
			if(!vis[to[i]])
			{
				v=to[i];
				break;
			}
		if(!v)break;
		que.push_front(v);
		u=v;
	}
	printf("%d\n",que.size());
	for(int i:que)
		printf("%d ",i);
}


Measured memory_bytes: 3200
#include <vector>
#include <iostream>
#include <string>

using namespace std;

const unsigned int M = 1000000007;

struct Node {
	unsigned int num;
	unsigned int tmp;
	Node *a, *g, *c, *t;
	Node () {
		num = tmp = 0;
	}
	void add(unsigned int n) {
		tmp += n;
		tmp %= M;
	}

	void next_gen() {
		num = tmp;
		tmp = 0;
	}
};


int main() {
	Node *root;
	Node end;
	Node *a, *ag, *agg, *agt, *ac, *at, *atg, *g, *ga;
	vector<Node> ar(10);
	root = &ar[0];
	a = &ar[1];
	ag = &ar[2];
	agg = &ar[3];
	agt = &ar[4];
	ac = &ar[5];
	at = &ar[6];
	atg = &ar[7];
	g = &ar[8];
	ga = &ar[9];

	root->a = a;
	root->g = g;
	root->c = root;
	root->t = root;

	a->a = a;
	a->g = ag;
	a->c = ac;
	a->t = at;

	ag->a = ga;
	ag->g = agg;
	ag->c = &end;
	ag->t = agt;

	agg->a = ga;
	agg->g = g;
	agg->c = &end;
	agg->t = root;

	agt->a = a;
	agt->g = g;
	agt->c = &end;
	agt->t = root;

	ac->a = a;
	ac->g = &end;
	ac->c = root;
	ac->t = root;

	at->a = a;
	at->g = atg;
	at->c = root;
	at->t = root;

	atg->a = ga;
	atg->g = g;
	atg->c = &end;
	atg->t = root;

	g->a = ga;
	g->g = g;
	g->c = root;
	g->t = root;

	ga->a = a;
	ga->g = ag;
	ga->c = &end;
	ga->t = at;

	root->num = 1;

	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		for(auto &x: ar) {
			x.a->add(x.num);
			x.g->add(x.num);
			x.c->add(x.num);
			x.t->add(x.num);
		}
		for(auto &x: ar) x.next_gen();
	}

	int sum = 0;
	for(auto &x: ar) {
		sum += x.num;
		sum %= M;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
main = do
  s <- getLine
  let ans = compute s
  putStrLn (if ans then "Yes" else "No")

compute :: String -> Bool
compute s = p s && p s1 && p s2
  where
    l = length s
    s1 = take (l `div` 2) s
    s2 = drop (pred ((l + 3) `div` 2)) s

p :: String -> Bool
p s = reverse s == s


Measured memory_bytes: 508
#include<stdio.h>
#include<math.h>
int main ()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if((a+b)%2==0)
    {
        printf("%d\n",(a+b)/2);
    }
    else printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<deque>
#include<algorithm>
#include<cmath>

using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    deque<int> a(n);

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

    deque<int> ans;

        for(int i = 0; i < n; ++i) {
            // if ((i+1)&1 == n&1) {
            if((i+1)%2 == n%2) {
                // cout << "eq" << endl;
                ans.push_front(a[i]);
            } else {
                // cout << "neq" << endl;
                ans.push_back(a[i]);
            }

            // for_each(ans.begin(), ans.end(),[](int x) {cout << x << " ";});
            // cout << endl;
        }

    for(size_t i = 0; i < ans.size(); ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int row[1111],col[1111];
int main()
{
    int n,m,a,b;scanf("%d%d%d%d",&n,&m,&a,&b);
    map<int,int> ss;
    for(int i=0;i<=n;i++)ss[a*i+(m-a)*(n-i)]=i;
    int flag=0;
    for(int i=0;i<=m;i++)
    {
        int k=(b*i+(n-b)*(m-i));
        if(ss.count(k)){
            int x=ss[k];
            for(int j=1;j<=x;j++)row[j]=a;
            for(int j=x+1;j<=n;j++)row[j]=m-a;
            for(int j=1;j<=i;j++)col[j]=b;
            for(int j=i+1;j<=m;j++)col[j]=n-b;
            flag=1;
            break;
        }
    }
    if(!flag){printf("-1\n");return 0;}
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            if(row[i]&&col[j])
            {
                row[i]--,col[j]--;
                putchar('1');
            }
            else putchar('0');
            puts("");
    }
}

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

int main(){
  string s;
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
  }

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)

//v4
int cond = 1;
string to_string(char c){return'\''+string(1,c)+'\'';}
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(std::vector<bool>::reference&r){return to_string((bool)r);}
template<typename A,typename B>string to_string(const pair<A,B>&p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A>string to_string(A v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x);}r+="}";return r;}
template<typename A,typename B>string to_string(map<A,B>v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x.first)+" -> "+to_string(x.second);}r+="}";return r;}
void __db(int i,const vector<string>&s){cerr<<endl;}
template<typename T,typename... A>void __db(int i,const vector<string>&s,T t,A... a){if(i)cerr<<", ";cerr<<s[i]<<" = "<<to_string(t);__db(i+1,s,a...);}
string __cl(string s){while(!s.empty()&&s[0]==' ')s.erase(0,1);while(!s.empty()&&s.back()==' ')s.pop_back();return s;}
vector<string>__vars(string s){vector<string>r;s+=",";string n="";int d=0;for(auto x:s)if(x==','&&d==0){if(!n.empty())r.push_back(__cl(n));n="";}else{n+=x;if(x=='('||x=='[')d++;else if(x==')'||x==']')d--;}return r;}
#define DB(...){if(cond){cerr<<"Line:"<<__LINE__<<" ";__db(0,__vars(#__VA_ARGS__),__VA_ARGS__);}}

int main() {
  int n;
  scanf("%d", &n);
  map<string, int> pop;
  FOR(i, 1, n) {
    auto x = to_string(i);
    pop[string(1, x[0])+string(1, x.back())]++;
  }
  LL res = 0;
  for (auto& x : pop) {
    auto tmp = x.first;
    reverse(tmp.begin(), tmp.end());
    if (pop.count(tmp)) {
      res += 1LL * x.second * pop[tmp];
    }
  }
  printf("%lld\n", res);
  return 0;
}

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

Measured memory_bytes: 1044
// Author: Mohammad Faisal
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int * arr = new int[n];
	
	vector<int> dup;
	for(int i=0;i<n;i++)
	{	
		cin >> arr[i];
		dup.push_back(arr[i]);
	}
	
	sort(dup.rbegin(),dup.rend());
	
	for(int i=0;i<n;i++)
	{
		if(arr[i] == dup[0])
			cout<<dup[1]<<endl;
		else
			cout<<dup[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3316