akhauriyash/Code-Regression huggingface dataset:
while True:
    n=input()
    if n==0:break
    Lok=Lng=Dok=Dng=Mok=Mng=0
    for i in range(n):
        temp=raw_input().split()
        MM=int(temp[1])
        hh,mm=map(int,temp[0].split(":"))
        diff=MM-mm if MM-mm>=0 else MM-mm+60
        if 11<=hh<15:
            if diff<=8:
                Lok+=1
            else:
                Lng+=1
        elif 18<=hh<21:
            if diff<=8:
                Dok+=1
            else:
                Dng+=1
        elif 21<=hh<=23 or 0<=hh<2:
            if diff<=8:
                Mok+=1
            else:
                Mng+=1
    print "lunch",int(float(Lok)/(Lok+Lng)*100) if Lok+Lng!=0 else "no guest"
    print "dinner",int(float(Dok)/(Dok+Dng)*100) if Dok+Dng!=0 else "no guest"
    print "midnight",int(float(Mok)/(Mok+Mng)*100) if Mok+Mng!=0 else "no guest"

Measured memory_bytes: 4300
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51], goal_state, next;
	register int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = i;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a, b;
	string op;
	cin >> a >> op >> b;

	if(op == "+")
		cout << a + b << endl;
	else
		cout << a - b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#%%code
def resolve():
    N=int(input())
    S=input()
    RGB=[0,0,0]
    subcnt=0
    for i,c in enumerate(S):
        if c=="R":RGB[0]+=1
        if c=="G":RGB[1]+=1
        if c=="B":RGB[2]+=1
            
        for j in range(i+1,N):
            s=S[j]
            k=j*2-i
            if k<N :
                x=S[k]
                if   x!=s and s!=c and x!=c :
                    #print(i,j,k)
                    
                    subcnt+=1
            else:break

    #print(RGB,subcnt)
    A=RGB[0]*RGB[1]*RGB[2]
    print(A-subcnt)
            
#%%submit!
resolve()

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

//const ll mod = static_cast<int>(1e9 + 7);



int main() {
	int N;
	cin >> N;

	int cnt = 0;
	int N_cpy = N;
	while (N_cpy > 0) {
		N_cpy /= 10;
		++cnt;
	}

	if (cnt <= 2) {
		cout << min(N, 9) << endl;
	}
	else {
		int ans = 0;
		ans += 9;
		int M = 100;
		for (int i = 3; i <= cnt; i += 2) {
			if (i == cnt) {
				int num = N - M;
				ans += num + 1;
			}
			else {
				ans += M * 9;
			}
			M *= 100;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		long c = stdIn.nextLong();
		
		for(int i = 0; i < (int)1e8; i++) {
			if((b*i+c)/a == (b*i+c)/(double)a) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
		
	}

}


Measured memory_bytes: 22868
<?php
$myarray = array();
for($i = 0; $i < 2; $i++) {
    $l = trim(fgets(STDIN));
    $myarray[$i] = $l;
}

$count1 = 0;
$count2 = 0;
for($i = 0; $i < strlen($myarray[0]) * 2; $i++) {
    if($i % 2 == 0) {
        echo substr($myarray[0], $count1, 1);
        $count1++;
    }else{
        echo substr($myarray[1], $count2, 1);
        $count2++;
    }
}

echo "\n";


Measured memory_bytes: 3956
/**
 * C - K-th Substring
 */

#include <iostream>
#include <set>

using namespace std;

int main() {

    string s;
    int K;
    set<string> set;

    cin >> s >> K;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= K; j++) {
            set.insert(s.substr(i, j));
        }
    }

    int i = 1;
    for (string s_ :set) {
        if (i == K) {
            cout << s_ << endl;
            break;
        }
        i++;
    }
}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String A = S.substring(0,1);
      String B = S.substring(1,2);
      String C = S.substring(2,3);
      String D = S.substring(3,4);
      if(A.equals(B) && B.equals(C) && C.equals(D)){
        System.out.println("No");
      }else if(A.equals(B)&&C.equals(D)||
               A.equals(C)&&B.equals(D)||
               A.equals(D)&&B.equals(C)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}     

Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  int max_count = 0;
  for(auto& s : S){
    count += (s=='I'?1:-1);
    max_count = max(max_count, count);
  }
  cout << max_count << endl;
  return 0;
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cout<<n*n + n + n*n*n;
}



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

int main(){
  int r, D, x2000;
  cin >> r>> D >> x2000;
  
  int x = x2000 ;
  for(int i = 0; i < 10; i++){
    x = r * x - D;
  cout << x << endl;
  }

    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
signed main()
{
	int a, b;
	cin >> a >> b;
	if (a % (2 * b + 1))
		cout << a / (2 * b + 1) + 1;
	else
		cout << a / (2 * b + 1); 
}











Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(10);
	if (x == 0 || w == x || y == 0 || h == y) {
		cout << h * w / 2.000 << " 0" << endl;
		return 0;
	}
	long double ans = max(min(x, w - x) * h, min(y, h - y) * w);
	cout << h*w / 2.00 << " ";
	int ok = 0;
	if (abs(min(x, w - x) * h - min(y, h - y) * w) < eps) {
		ok = 1;
	}
	if (abs(ans - min(x, w - x) * h) < eps && y == h - y) {
		ok = 1;
	}
	if (abs(ans - min(y, h - y) * w) < eps && x == w - x) {
		ok = 1;
	}
	cout << ok << endl;
}


Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int n, k;

	cin >> n >> k;

	vector<int> p(n), rp(n + 1);

	rp[0] = 0;

	REP(i, n) {
		cin >> p[i];
		rp[i + 1] = p[i] + rp[i];
	}

	double res = 0;

	REP(i, n - k + 1) {
		double w = (double)rp[i + k] - rp[i];
		res = max(res, (w - k) / 2 + k);
	}

	cout << fixed << setprecision(12) << res << '\n';

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll h,w;
	rl2(h,w);
	vector<string> arr(h);
	fr(i,0,h)
		cin>>arr[i];
	vector<VL> row(h,VL()),col(w,VL());
	fr(i,0,h)
	{
		fr(j,0,w)
		{
			if(arr[i][j]=='#')
			{
				row[i].PB(j);
				col[j].PB(i);
			}
		}
	}
	ll ans=0;
	fr(i,0,h)
	{
		fr(j,0,w)
		{
			ll z=0;
			if(arr[i][j]!='#')
			{
				VL::iterator l1,l2;
				l1=lower_bound(ALL(row[i]),j);
				l2=lower_bound(ALL(col[j]),i);
				ll x=l1-row[i].begin();
				ll y=l2-col[j].begin();
				
				if(SZ(row[i])==0)
					z+=w;
				else if(SZ(row[i])==x)
				{
					z+=(w-1-row[i][x-1]);
				}
				else if(x==0)
				{
					z+=row[i][x]+1;
				}
				else
				{
					z+=(row[i][x]-row[i][x-1]-1);
				}
				if(SZ(col[j])==0)
					z+=h;
				else if(SZ(col[j])==y)
				{
					z+=(h-1-col[j][y-1]);
				}
				else if(y==0)
				{
					z+=(col[j][y]+1);
				}
				else
				{
					z+=(col[j][y]-col[j][y-1]-1);
				}
				z-=1;	
			}
			ans=max(ans,z);
		}

	}
		if(ans==9)
			ans-=1;
		wl(ans);
		NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

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

void vector_sum(const std::vector<int>& a, std::vector<int>& sum) {
  for (int i = 0; i < a.size(); ++i) {
    sum[i] += a[i];
  }
}

int main() {
  int N, M, X;
  std::cin >> N >> M >> X;

  std::vector<int> C_array(N);
  std::vector<std::vector<int>> A_array(N, std::vector<int>(M, 0));

  for (int i = 0; i < N; ++i) {
    std::cin >> C_array[i];
    for (int j = 0; j < M; ++j) {
      std::cin >> A_array[i][j];
    }
  }

  const int inf = 100000000;
  int max_cost = inf;
  for (int bit = 0; bit < (1 << N); ++bit) {
    std::vector<int> sum(M, 0);
    int cost = 0;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        vector_sum(A_array[i], sum);
        cost += C_array[i];
      }
    }
    bool ok = true;
    for (int i = 0; i < M; ++i) {
      if (sum[i] < X) {
        ok = false;
        break;
      }
    }
    if (ok) {
      max_cost = std::min(max_cost, cost);
    }
  }

  if (max_cost == inf) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << max_cost << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	string S;
	cin >> S;
	int cnt = 0;
	int i = 0;
	while(i+1<S.size())
	{
		if (S[i] != S[i + 1])
		{
			cnt += 2;
			S.erase(S.begin() + i);
			S.erase(S.begin() + i);
			i = 0;
		}
		else
		{
			i++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int v = 1;
    rep(i, n) {
        v = min(v * 2, v + k);
    }
    put(v)
    
    return 0;
}

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

int main(){

  int x;
  cin>>x;

  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
 }



Measured memory_bytes: 3120
#include"bits/stdc++.h"
#include<math.h>
#include<vector>
using namespace std;
int64_t i,j,k,l;//preparation for
int main(){
    int n,m;
    cin>>n>>m;

    int e,f;
    e=n*(n-1)/2;
    f=m*(m-1)/2;

    cout<<e+f;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
    int a,b,c,i,n;

    scanf("%d",&n);
    for(i = 1; i <= n; i++){
	scanf("%d %d %d",&a ,&b ,&c);
	if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b){
	    printf("YES\n");
	}else{
		printf("NO\n");
	}
    }
    return 0;
} 

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				if(i * 500 + j * 100 > x) {
					break;
				}else if((x - i*500 - j*100)% 50 == 0 && (x - i*500 - j*100)/ 50 <= c) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main(){
  int a, b, c, d ;
  cin >> a >> b >> c >> d ;
  while(1){
    c -= b ;
    if(c <= 0){
      cout << "Yes" ;
      break ;
    }
    a -= d ;
    if(a <= 0){
      cout << "No" ;
      break ;
    }
  }
  return 0 ;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    for (int i = 0; i < n; i++) {
        s[i] -= '0';
    }

    int r = 0;
    for (int h = 0; h < 1000; h++) {
        int p[3];
        int t = h;
        for (int j = 0; j < 3; j++) {
            p[j] = t % 10; t /= 10;
        }
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == p[j]) {
                j++;
                if (j == 3) {
                    r++;
                    break;
                }
            }
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
const int N=305;
struct node{
	LL w,x,y;
}edge[N*N*3];
LL dis[N][N],a[N][N],n,tot,ans;
int cmp(node a,node b)
{
	return a.w>b.w;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	 for(int j=1;j<=n;++j)
	{
		scanf("%lld",&a[i][j]);
		dis[i][j]=a[i][j];
	    edge[++tot].x=i;edge[tot].y=j;edge[tot].w=a[i][j];
	    ans=ans+a[i][j];
	}
	for(int k=1;k<=n;++k)
	 for(int j=1;j<=n;++j)
	  for(int i=1;i<=n;++i)
	   if(dis[i][k]+dis[k][j]<dis[i][j])
	    dis[i][j]=dis[i][k]+dis[k][j];
	
	int flag=1;
	for(int i=1;i<=n;++i)
	 for(int j=1;j<=n;++j)
	  if(a[i][j]!=dis[i][j])
	   flag=-1;
	
	if(flag==-1) 
	{
		printf("-1\n");
		return 0;
	}
	
	
	sort(edge+1,edge+tot+1,cmp);
	for(int i=1;i<=tot;++i)
	{
		int x=edge[i].x;
		int y=edge[i].y;
		int hh=0;
		for(int j=1;j<=n;++j)
		 if(j!=x&&j!=y)
		  if(dis[x][j]+dis[j][y]==dis[x][y])
	        hh=1;
	    if(hh) ans=ans-edge[i].w;
	}
    cout<<ans/2<<endl;	
	return 0;
}

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

void show(int** a, int n)
{
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) std::cout << a[i][j] << " ";
		std::cout <<std::endl;
	}
}

int main()
{
	int n; std::cin >> n;
	int** D = new int*[n];
	for (int i=0; i<n; i++) D[i] = new int[n];
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) D[i][j] = (i==j) ? 0 : n;
	}
	for (int i=0; i<n; i++) {
		int s; std::cin >> s;
		int k; std::cin >> k;
		for (int j=0; j<k; j++) {
			int t; std::cin >> t;
			D[s-1][t-1] = 1;
		}
	}
	
	//show(D, n);
	// Floyd-Warshall
	for (int k=0; k<n; k++) {
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				D[i][j] = std::min(D[i][j], D[i][k] + D[k][j]);
			}
		}
		//std::cout << k << std::endl;
		//show(D, n);
	}
	
	int p; std::cin >> p;
	for (int i=0; i<p; i++) {
		int s, t, v;
		std::cin >> s >> t >> v;
		if (D[s-1][t-1] < n && D[s-1][t-1]+1 <= v) std::cout << D[s-1][t-1]+1 << std::endl;
		else std::cout << "NA" << std::endl;
	}
	
	for (int i=0; i<n; i++) delete[] D[i];
	delete[] D;
		
	return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
        int n, i;
        int *a;

        scanf("%d", &n);

        a = (int *)malloc(sizeof(int) * n);

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

        for (i = n - 1; i >= 0; i--) {
                if (i != 0) printf("%d ", a[i]);
                else printf("%d\n", a[i]);
        }

        return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
 
int main(void) {
    int h, w;
    int i, j;
     
    while (scanf("%d %d", &h, &w), h || w) {
 
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1) putchar('#');
                else putchar('.');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 1; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		Dice dice = new Dice(array);
		int part1; int part2;
		for (int i = 0; i < q; i++) {
			part1 = scan.nextInt();
			part2 = scan.nextInt();
			System.out.println(dice.check(part1, part2));
		}
		scan.close();
	}
}
	

class Dice {
	private int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = getNum();
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_2]; cp_array[6] = array[7 -now_1];
		return cp_array;
	}
	
	// ????¨?????????????????????????
	public int[] turn(int[] array) {
		int tmp;
		tmp = array[2];
		array[2] = array[3];
		array[3] = array[5];
		array[5] = array[4];
		array[4] = tmp;
		
		return array;
	}
	
	// 3?????¨?????????????????????
	public int check(int part1, int part2) {
		String[] str = {"null", "N", "NN", "S", "W", "E"};
		int sum = 0;
		int[] array = new int[num.length];
		for (int i = 0; i < num.length; i++) {
			array[i] = num[i];
		}
		boolean decision = false;
		for (int i = 0; i < str.length; i++) {
			array = this.roll(str[i]);
			for (int j = 0; j < 4; j++) {
				if (array[1] == part1)
					if (array[2] == part2) {
						sum = array[3];
						decision = true;
						break;
					} else {
						array = this.turn(array);
					}
			}
			if (decision) break;
		}
		

		return sum;
	}
	
	public void print(int[] array) {
		for (int i = 1; i < array.length; i++) {
			System.out.println(array[i]);
		}
	}
}

Measured memory_bytes: 26164
def main():
    N, A, B = map(int, input().split())
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        case1 = (N - B) + 1 + (B - A - 1) // 2
        case2 = (A - 1) + 1 + (B - A - 1) // 2
        print(min(case1, case2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 39888
using System;
using System.IO;
using System.Text;

class Program{
    static void Main(string[] args){
        var N = new StringBuilder(Convert.ToString(int.Parse(Console.ReadLine()), 2));
        N.Replace('1', '0', 1, N.Length - 1);
        var answer = Convert.ToInt32(N.ToString(), 2);
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27452
//Created by Aminul on 8/2/2020.

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int cnt = 0;
        int n = in.nextInt();
        long d = in.nextInt();
        d = d * d;
        for (int i = 0; i < n; i++) {
            long x = in.nextInt(), y = in.nextInt();
            long dist = (x * x) + (y * y);
            if(dist <= d) cnt++;
        }
        pw.println(cnt);
          
        pw.close();
    }


    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 48936
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string s,p;cin>>s>>p;
    rep(i,s.size()){
        bool flag=true;
        rep(j,p.size())if(s[j]!=p[j]){
            flag=false;
            break;
        }

        if(flag){
            cout<<"Yes"<<endl;
            return 0;
        }
        s=s[s.size()-1]+s.substr(0,s.size()-1);
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main() {
	
	string str;
	cin >> str;
	
	if(str.size() < 26){
		bool flag[26] = {};
		for(int i = 0; i < str.size(); i++){
			flag[str[i] - 'a'] = true;
		}
		string ss = " ";
		for(int i = 0; i < 26; i++){
			if(!flag[i]){
				ss[0] = 'a' + i;
				break;
			}
		}
		cout << str << ss << endl;
		return 0;
	}else{
		int id, id2;
		for(int i = str.size() - 1; i > 0; i--){
			if(str[i] > str[i - 1]){
				id = i;
				for(int j = id; j < str.size(); j++){
					if(str[id - 1] < str[j]){
						id2 = j;
					}
				}
				string ss = " ";
				ss[0] = str[id2];
				cout << str.substr(0, i - 1) << ss << endl;
				return 0;
			}
		}
	}
	
	cout << "-1" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define HASH 1000003

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = (x * 337 + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 337, HASH);
	for (k = 1, pow[0] = 337; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				for (p = hash[h[i]]; p != NULL; p = p->next) if (p->l == l[i] - j && p->s[0] == T[j] && lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (T[j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 23592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int>dp(n+1,0);
  for(int i=0;i<n-1;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='C'){
      dp[i+1]=1;
    }
    dp[i+1]+=dp[i];
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    r--;
    l--;
    cout << (dp[r]-dp[l]) << endl;
  }
}

Measured memory_bytes: 3848
#include<iostream>

using namespace std;

int main(void){
  
  int price = 700;
  string str;
  cin >> str;
  
  for(int i = 0; i < 3; ++i){
    if(str[i] == 'o') price += 100;
  }
  
  cout << price << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int R;
    std::cin >> R;
    if (R < 1200){
        std::cout << "ABC";
    }
    else if (R < 2800 && R >= 1200){
        std::cout << "ARC";
    }
    else
        std::cout << "AGC";
    return 0;
}

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

using namespace std;

int main()
{
    long long n, m, x;
    x = pow(2, 31) - 1;
    cin >> n >> m;
    long long ans = m;
    for (int i = 1; i < n; ++i)
    {
        ans = (ans * (m - 1)) % x;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int bas=0;bas<=100000;bas++)
	{
		int tmp = n-bas*100;
		if(tmp>=0&&tmp<=5*bas)
		{
			cout<<1<<'\n'; return 0;
		}
	}
	cout<<0<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int a(int n)
{
	int d,s=0;
	while(n){
		d=n%10;
		s=s+d;
		n=n/10;
	}
	return s;
}

int main(void)
{
	int n,f;
	scanf("%d",&n);
	f=a(n);
	if(n%f==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int P[8];
int Q[8];
int fac[10];
int solve(int n, int p[]){
  int i;
  int res = 0;
  for(i=(0);i<(n);i++){
    int j;
    for(j=(i+1);j<(n);j++){
      if(p[j] < p[i]){
        res += fac[n-i-1];
      }
    }
  }
  return res;
}
int main(){
  int i;
  int res;
  rd(N);
  {
    int cTE1_r3A;
    for(cTE1_r3A=(0);cTE1_r3A<(N);cTE1_r3A++){
      rd(P[cTE1_r3A]);P[cTE1_r3A] += (-1);
    }
  }
  {
    int xr20shxY;
    for(xr20shxY=(0);xr20shxY<(N);xr20shxY++){
      rd(Q[xr20shxY]);Q[xr20shxY] += (-1);
    }
  }
  fac[0] = 1;
  for(i=(0);i<(10);i++){
    fac[i+1] = (i+1) * fac[i];
  }
  res = abs(solve(N,P) - solve(N,Q));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// int N, P[8], Q[8];
// int fac[10];
// 
// int solve(int n, int p[]){
//   int res = 0;
//   rep(i,n){
//     rep(j,i+1,n) if(p[j] < p[i]) res += fac[n-i-1];
//   }
//   return res;
// }
// 
// {
//   int res;
//   rd(N,(P--)(N),(Q--)(N));
//   
//   fac[0] = 1;
//   rep(i,10) fac[i+1] = (i+1) * fac[i];
// 
//   res = abs(solve(N,P) - solve(N,Q));
//   wt(res);
// }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;

	int[][] path;
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			int x = Integer.parseInt(sc.nextLine());
			int h = Integer.parseInt(sc.nextLine());
			if ((x == 0) && (h == 0)) break;
			
			System.out.println(x * x + x * Math.sqrt((x / 2.0) * (x / 2.0) + h * h) * 2);
		}
	}
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int n,a,b;
    cin >> n >> a >> b;

    pl(min(b,n*a))

    return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    if(n % 2 == 1){
        cout << n / 2 + 1 << endl;
    }else{
        cout << n / 2 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
	int n;	// total
	int a[20];
	int b[50];
	int c[50];
	int s_sum;
	int k;

	scanf("%d", &n);

	for(k = 0; k < n; k++){
		scanf("%d", &a[k]);
	}
	for(k = 0; k < n; k++){
		scanf("%d", &b[k]);
	}
	for(k = 0; k < n-1; k++){
		scanf("%d", &c[k]);
	}

	s_sum = 0;
	for(k = 0; k < n; k++){
		s_sum += b[a[k]-1];
		if ((k >= 1)&&(a[k]-a[k-1]==1)) {
			s_sum += c[a[k-1]-1];
		}
	}

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

	return 0;
}


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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
    

Measured memory_bytes: 25716
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		string ans=new string('U',s[3]-s[1]);
		ans+=new string('R',s[2]-s[0]);
		ans+=new string('D',s[3]-s[1]);
		ans+=new string('L',s[2]-s[0]+1);
		ans+=new string('U',s[3]-s[1]+1);
		ans+=new string('R',s[2]-s[0]+1);
		ans+="DR";
		ans+=new string('D',s[3]-s[1]+1);
		ans+=new string('L',s[2]-s[0]+1);
		ans+="U";
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13140
using System;

namespace ABC164A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] word = Console.ReadLine().Split(' ');
            int s = int.Parse(word[0]);
            int w= int.Parse(word[1]);

            if (s > w)
                Console.WriteLine("safe");
            else if (s <= w)
                Console.WriteLine("unsafe");
        }
    }
}

Measured memory_bytes: 27428
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()

int main() {
    int n;
    scanf("%d", &n);
    vector<int> vec(n+1);
    rep(i,n) scanf("%d", &vec.at(i));
    vec.at(n) = 2020;
    int m;
    scanf("%d", &m);
    rep(i,m) {
        int c;
        scanf("%d", &c);
        if (vec.at(c) != vec.at(c-1)+1) vec.at(c-1)++;
    }
    rep(i,n) printf("%d\n", vec.at(i));
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const double PI = 3.14159265358979;
ll n,k,r,s,p;
string t;
ll win(char T){
    if(T=='r') return p;
    else if(T=='s') return r;
    else return s;
}
void Main(){
    cin>>n>>k>>r>>s>>p>>t;
    ll score[100010];
    bool flag[100010];
    score[0]=0;
    For(i,1,n+1){
        if(i>k){
            if(t[i-1]==t[i-k-1]&&flag[i-k]==true){
                score[i]=score[i-1];
                flag[i]=false;
            }
            else {
                score[i]=score[i-1]+win(t[i-1]);
                flag[i]=true;
            }            

        }
        else{
            score[i]=score[i-1]+win(t[i-1]);
            flag[i]=true;
        }
    }
    cout<<score[n]<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int ans[1261][10001]={};


int main() 
{
	int N,M;
	while(cin>>N>>M&&!(N==0&&N==0)){ //N=pc  M=students
		
		REP(j,1261){REP(k,10001){ans[j][k]=0;}}	
		
		int r;	cin>>r;
		for(int i=0;i<r;i++){
			int t,m,n,s;
			cin>>t>>n>>m>>s;
			m--;n--;
			
			if(s==1){
				for(int j=t;j<1260;j++){
					ans[j][m]++;
				}
			}
			else{
				for(int j=t;j<1260;j++){
					ans[j][m]--;
				}
			}
		}
		
		int q;	cin>>q;
		for(int i=0;i<q;i++){
			int s,e,m;
			cin>>s>>e>>m;
			m--;
			int tmp(0);
			for(int j=s;j<e;j++){
				if(ans[j][m]>0){
					tmp++;
				}
			}
			cout<<tmp<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 50420
n =int(input())
ans =[0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i
			if v<10050:               
				ans[v]+=1
for i in range(n):print(ans[i+1])

Measured memory_bytes: 9312
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef pair<int,int>P;
#define X first
#define Y second
/*
オセロ
oxoxox
*/

char mp[10][10];

int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};

int pos_cnt(P p){
	int cnt=0;
	for(int i=0;i<8;i++){
		for(int j=1;true;j++){
			if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]=='.'||mp[p.X+j*dx[i]][p.Y+j*dy[i]]=='*')break;
			if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]==mp[p.X][p.Y]){
				cnt+=(j-1);
				break;
			}
		}
	}
	return cnt;
}

P pos_check(char c){
	P p;p.X=-1;p.Y=-1;
	int mx=0;
	
	if(c=='o'){
		for(int i=1;i<=8;i++){
			for(int j=1;j<=8;j++){
				if(mp[j][i]=='.'){
					mp[j][i]=c;
					int tmp=pos_cnt(P(j,i));
					if(mx<tmp){
						p.X=j;
						p.Y=i;
						mx=tmp;
					}
					mp[j][i]='.';
				}
			}
		}
	}else{
		for(int i=8;i>=1;i--){
			for(int j=8;j>=1;j--){
				if(mp[j][i]=='.'){
					
					mp[j][i]=c;
					int tmp=pos_cnt(P(j,i));
					if(mx<tmp){
						p.X=j;
						p.Y=i;
						mx=tmp;
					}
					mp[j][i]='.';
					
				}
			}
		}
	}
	return p;
}

void pos_change(P p){
	for(int i=0;i<8;i++){
		int f=0;
		for(int j=1;true;j++){
			if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]=='.'||mp[p.X+j*dx[i]][p.Y+j*dy[i]]=='*')break;
			if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]==mp[p.X][p.Y]){
				f=1;
				break;
			}
		}
		for(int j=1;f;j++){
			if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]!=mp[p.X][p.Y])mp[p.X+j*dx[i]][p.Y+j*dy[i]]=mp[p.X][p.Y];
			else if(mp[p.X+j*dx[i]][p.Y+j*dy[i]]==mp[p.X][p.Y])break;
		}
	}
}


int main(){
	//初期化
	memset(mp,'.',sizeof(mp));
	//入力
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cin>>mp[j][i];
		}
	}
	
	//oから始まる
	char turn='o';
	
	//2回連続でどこにもおけなかったら終了
	for(int dame=0;dame<2;){
		//おける場所を探す
		P p=pos_check(turn);
		if(p.X<0){
			//置けない
			dame++;
		}else{
			//おける
			dame=0;
			//おける場所に置く
			mp[p.X][p.Y]=turn;
			//ひっくり返す
			pos_change(p);
		}
		
		//ターン変更
		if(turn=='o')turn='x';
		else if(turn=='x')turn='o';
		
	}
	
	//出力
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cout<<mp[j][i];
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1136
class FUnionFind
  attr_reader :nodes, :parents, :ranks

  def initialize(n)
    @parents = (0...n).to_a
    @nodes = @parents.map{ |x| [x] }
  end

  def find(i)
    @parents[i]
  end

  def union(i,j)
    i = @parents[i]; j = @parents[j]
    return if i == j
    j,i = i,j if @nodes[i].size < @nodes[j].size
    #p [i,j,@nodes[i],@nodes[j]]
    #p [i,j,@nodes[i].size,@nodes[j].size]
    @nodes[j].each{ |k| @parents[k] = i }
    @nodes[i].concat(@nodes[j])
    @nodes[j].clear
  end

  def setsize(i)
    @nodes[find(i)].size
  end
end

N,K,L = gets.split.map &:to_i
uf_road = FUnionFind.new(N)
K.times{
  u,v = gets.split.map &:to_i
  uf_road.union(u-1, v-1)
}
uf_rail = FUnionFind.new(N)
L.times{
  u,v = gets.split.map &:to_i
  uf_rail.union(u-1, v-1)
}

memo = {}
counts = {}
(0...N).each{ |u|
  sig = [uf_road.find(u), uf_rail.find(u)]
  counts[sig] ||= 0
  counts[sig] += 1
  memo[u] = sig
}
puts (0...N).map{ |u| counts[ memo[u] ] } * " "


Measured memory_bytes: 70268
#include<iostream>
using namespace std;
#define MAX 5000

class Tetoris{
    public:
    int stack[MAX+1], top;
    Tetoris(){ stack[0] = 31; top = 0; }
    
    void insert( int o, int p, int q ){
        int value = (o == 1 ? (((2 << p-1)-1) << (q-1)) : (1 << (q-1)));
        int target = getTarget( value );
        for ( int i = target;  i < target + ((o == 2) ? p : 1); i++ ){
            if ( i > top ){
                stack[i] = value;
                top = i;
            } else {
                stack[i] += value;
            }
        }
        
        while( erase());
    }
    
    bool erase(){
        for ( int i = 1; i <= top; i++ ){
            if ( stack[i] == 31 ){
                for ( int j = i+1; j <= top; j++ ) stack[j-1] = stack[j];
                top--; return true;
            }
        }
        return false;
    }
    
    int getResult(){
        int sum = 0;
        for ( int i = top; i >= 1; i-- ){
            int val = stack[i];
            while( val ){
                if ( val%2 ) sum++;
                val /= 2;
            }
        }
        return sum;
    }
    
    int getTarget( int value ){
        int target = top;
        while( (stack[target] & value) == 0 ) target--;
        return target + 1;
    }
};

int main(){
    int n, o, p, q;
    while( cin >> n && n ){
        Tetoris tetoris;
        for ( int i = 0; i < n; i++ ) {
            cin >> o >> p >> q;
            tetoris.insert(o, p, q);
        }
        cout << tetoris.getResult() << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define x first
#define y second

const ll inf=2147483647;

//

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

void print(ll x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}

int a,b;

int main(){
	a=read();
	b=read();
	if(a%b==0){
		cout<<-1<<endl;
	}
	else{
		ll ans=a*1ll*(b-1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256