akhauriyash/Code-Regression huggingface dataset:
def rec(i):
    global ans
    ans[N] = 1
    for i in range(N-1,-1,-1):
        if a[i+1] and a[i+2]:
            ans[i] = (ans[i+1] + ans[i+2])
        elif a[i+1]:
            ans[i] = ans[i+1]
        else:
            ans[i] = ans[i+2]
    return ans[0]

N, M = map(int, input().split())
A = [int(input()) for i in range(M)]

hantei = False
a = [True] * (N+1) + [False]
for i in range(0,M-1):
    if A[i+1] - A[i] == 1:
        hantei = True
        break

ans = [1] * (N+1)
if not hantei:
    for i in range(M):
        a[A[i]] = False
    Answer = rec(0)

if hantei:
    print(0)
else:
    print(Answer%1000000007)


Measured memory_bytes: 460772
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [n, x] <- map (read::String -> Int) . words <$> getLine 
  arr <- sort <$> forM [1..n] (\_ -> (read::String -> Int) <$> getLine)
  let all = sum arr
  print $ n + (x - all) `div` arr !! 0

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

int main(){
  int i,j;ll cnt;
  int n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll sum=0;
  for(i=0;i<n;i++)sum+=a[i];
  cnt=a[0];
  ll mi=max(sum-2*a[0],2*a[0]-sum);
  for(i=1;i<n-1;i++){
    cnt+=a[i];
    mi=min(max(sum-2*cnt,2*cnt-sum),mi);
  }
  cout<<mi;
}

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

using namespace std;
int main(){
  int n;
  string ans = "NO";
  cin >> n;

  int count = 0;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a%2!=0)count++;
  }
  
  if(count%2==0)ans="YES";
  cout << ans << endl;
}


Measured memory_bytes: 384
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Uset<Int> s;
	bool yes = true;
	Int N; cin >> N;
	rep(i, N) {
		Int A; cin >> A;
		pair<decltype(s)::iterator, bool> res = s.insert(A);
		if (!res.second)yes = false;
	}

	if (yes)cout << "YES";
	else cout << "NO";

}

Measured memory_bytes: 8520
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    vector<string> v(K);

    REP(i, T.size()) {
        v[i % K] += T[i];
    }

    map<char, ll> scores;
    scores['r'] = P;
    scores['s'] = R;
    scores['p'] = S;


    ll ans = 0;
    REP(i, v.size()) {
        bool state = false;

        if (v[i].empty()) continue;

        ans += scores[v[i][0]];
        FOR(j, 1, v[i].size()) {
            if (v[i][j] != v[i][j - 1]) {
                state = false;
                ans += scores[v[i][j]];
            } else {
                if (state) ans += scores[v[i][j]];
                state ^= true;
            }
        }
    }

    print(ans);

    
}


Measured memory_bytes: 6056
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int Y = sc.nextInt();
        boolean flg = true;
        for(int i = 0; i <= N; i++){
            for(int j = 0; j <= N-i; j++){
                int k = N-i-j;
                if(10000*i+5000*j+1000*k == Y){
                    System.out.print(i+" ");
                    System.out.print(j+" ");
                    System.out.println(k);
                    flg = false;
                }
            }
            if(!flg){
                break;
            }
        }
        if(flg){
            System.out.println("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#include<cstdlib>
#define ll long long int
#define ar array
const int inf=1e9+5;
int main() 
{
	int n,k;
	ll sum=0;
	cin>>n;
	cin>>k;
	int a[100000];
	vector<int>dp(n,inf);
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	dp[0]=0;
	//cout<<"\n dp[1]"<<dp[1];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<=i+k;j++)		
			if(j<n)
			{
				//cout<<"\n dp[j] "<<dp[j];
				dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
				
			}
	cout<<dp[n-1];		
}

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

int main() {
    int n,d,x; cin >> n >> d >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = n;
    for(int i = 0; i < n; i++){
        int v = a[i];
        a[i]++;
        while(a[i] <= d){
            cnt++;
            a[i] += v;
        }
    }
    cout << cnt + x;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <map>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

map < string, int > mp;
ll Ans; int n;

bool cmp(char x, char y) {
    return x < y;
}

int main() {
    string s;
    rep (i, 1, n = read<int>()) {
        cin >> s;
        sort(&s[0], &s[10]);
        Ans += mp[s];
        ++mp[s];
    }

    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 11136
h, w = map(int, input().split())
s = []

for i in range(h):
    S = list(input().split())
    s.append(S)

for i in range(h):
    for j in range(w):
        if s[i][j] == "snuke":
            l = chr(ord("A") + j)
            print(l + str(i + 1))
            exit()

Measured memory_bytes: 9152
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
count :: (a -> Bool) -> [a] -> Int
count = (length .) . filter
-- end of templete

f :: [Int] -> (Int, Int)
f (i:ss) = (negate $ g 1 ss, i)
  where
    g 11 _ = 0
    g n (10:xs@(s:t:_)) = 10 + s + t + g (n+1) xs
    g n (x:y:ys)
      | x+y==10 = 10 + head ys + g (n+1) ys
      | otherwise = x + y + g (n+1) ys

main = do
    n <- getInt
    when (n/=0) $ do
        sort . map f <$> replicateM n getInts >>= mapM_ (\(ns, i) -> putStrLn $ sjoin [i, -ns])
        main


Measured memory_bytes: 4552
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

int main() {
	string n;
	cin >> n;
	char x = n[n.size() - 1];

	string ans;
	if (x == '3') {
		ans = "bon";
	}
	else if (x == '0' || x == '1' || x == '6' || x == '8') {
		ans = "pon";
	}
	else ans = "hon";

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
int sum(int num){ //各桁の和を求める関数
  int sum=0;
  while(num>0){
    sum = sum + num%10 ;
    num = num/10 ;
  }
  return sum;
}

#include <stdio.h>
int main(void){
  int N,i,A,B,min=100;
  scanf("%d",&N);
  for(i=1;i<= 1+N/2 ;i++){
    A = i;
    B = N-i;
    if( (sum(A)+sum(B))< min ){
      min = sum(A) + sum(B);
    }
  }

  printf("%d\n",min);
  
  return 0;
}

Measured memory_bytes: 1696
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long

int main(void){
int X,A,B;
scanf("%d%d%d",&X,&A,&B);
if(A>=B) printf("delicious\n");
else if(A+X>=B) printf("safe\n");
else printf("dangerous\n");
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp mak_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double n,x,t;
	cin>>n>>x>>t;
	cout<<int(ceil(n/x)*t);
	return 0;
}

Measured memory_bytes: 3740
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll H,W; cin>>H>>W;
  vector<ll> vec(26,0); rep(i,H) rep(j,W) {char a; cin>>a; vec[a-'a']++;}
  
  if(H%2==0&&W%2==0){
    for(auto cha:vec) if(cha%4!=0) {cout<<"No"<<'\n'; return 0;}
    cout<<"Yes"<<'\n';
  }
  else if(H%2==1&&W%2==1){
    ll count=0,judge=0;
    for(auto num:vec){
      if(num%4==2) count++;
      if(num%4==1) judge++;
      if(num%4==3) {count++; judge++;}
    }
    cout<<(judge==1&&count<=H/2+W/2?"Yes":"No")<<'\n';
  }
  else if(H%2==1){
    ll count=0;
    for(auto num:vec) {if(num%4==2) count++; if(num%2==1) {cout<<"No"<<'\n'; return 0;}}
    cout<<(count<=W/2?"Yes":"No")<<'\n';
  }
  else if(W%2==1){
    ll count=0;
    for(auto num:vec) {if(num%4==2) count++; if(num%2==1) {cout<<"No"<<'\n'; return 0;}}
    cout<<(count<=H/2?"Yes":"No")<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	vector<int> v(n+2);
	vector<int> left(n+2, 0);
	vector<int> right(n+2, 0);
	for(int i=1; i<=n; i++)
		cin>>v[i];
	for(int i=1; i<=n; i++)
	{
		left[i] = __gcd(left[i-1], v[i]);
	}
	for(int i=n; i>=1; i--)
	{
		right[i] = __gcd(right[i+1], v[i]);
	}
	int maxPos = 1;
	for(int i=1; i<=n; i++)
	{
		int lrGCD = __gcd(left[i-1], right[i+1]);
		maxPos = max(lrGCD, maxPos);
	}
	cout<<maxPos<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4496
d = int(input())
c = list(map(int, input().split()))
s = []
li = [0]*26

for i in range(d):
    si = list(map(int, input().split()))
    s.append(si)

t = []

for i in range(d):
    t.append(int(input()))

ans = []
day = 0

for i in range(d):
    ti = t[i]
    day += s[i][ti-1]
    li[ti-1] = i+1
    for j in range(26):
        day -= c[j]*(i+1-li[j])
    ans.append(day)

for i in range(d):
    print(ans[i])

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

int main(){
  int N,x,y,z;
  x = 0;
  y = 0;
  cin >> N;
  z = N;
  while (z>0){
    x += z%10;
    if (x==1){
      y++;
    }
    z /= 10;
  }
  cout << x <<endl;
}

Measured memory_bytes: 3620
n,m,x,y = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
max_x = max(a)
min_y = min(b)
max_x = max(max_x,x)
min_y = min(min_y,y)

if max_x < min_y:
  print("No War")
else:
  print("War")

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

int main(){
  
  double a,b,c;
  cin >> a >> b >> c;
  
  if( a/c <= b ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}


Measured memory_bytes: 3716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int D;
    static int G;
    static int[] p;
    static int[] c;
    static void input()
    {
        cin = new Scanner();
        D = cin.nextInt();
        G = cin.nextInt();
        p = new int[D];
        c = new int[D];
        for (int i = 0; i < D; i++)
        {
            p[i] = cin.nextInt();
            c[i] = cin.nextInt();
        }
    }
    static void solve()
    {
        input();
        int[] dp = new int[D * 100 + 1];
        int sumP = 0;
        for (int d = 0; d < D; d++)
        {
            sumP += p[d];
            for (int i = sumP; i > 0; i--)
            {
                if (i - p[d] >= 0)
                    dp[i] = Max(dp[i], dp[i - p[d]] + (d + 1) * 100 * p[d] + c[d]);
                for (int j = 1; j <= p[d] && i - j >= 0; j++)
                {
                    dp[i] = Max(dp[i], dp[i - j] + 100 * (d + 1) * j);
                }
            }
        }
        for (int i = 1; i < dp.Length; i++)
        {
            if (dp[i] >= G)
            {
                WriteLine(i);
                return;
            }
        }
    }
    class Scanner
    {
        string[] s;
        int i;

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

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

        public int nextInt()
        {
            return int.Parse(next());
        }

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

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

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

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

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

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<numeric>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;



int main(void) {
	char a;
	cin >> a;
	if (isupper(a)) {
		cout << 'A';

	}
	else
		cout << 'a';




	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
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 all(a) (a).begin(),(a).end()
const long long INFTY =LLONG_MAX;
//ダイクストラ

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 1000002
long long n,color[MAX],d[MAX];
vector <pair<long long ,long long> > adj[MAX];
void dijkstra(){
    priority_queue <pair<long long,long long> > PQ;
    d[0]=0;
    color[0]=GRAY;
    PQ.push(make_pair(0,0));
    while(!PQ.empty()){
        pair<long long,long long> f=PQ.top();
        PQ.pop();
        long long u=f.second;
        color[u]=BLACK;
        if(d[u]<f.first*(-1)) continue;

        for(int j=0;j<adj[u].size();j++){
            long long v=adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    
}
int main(){
    long long u,k,w;
    cin>>n;
    REP(i,n-1){
        cin>>u>>k>>w;
        adj[u-1].push_back(make_pair(k-1,w));
        adj[k-1].push_back(make_pair(u-1,w));
    }
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        d[i]=INFTY;
    }
    dijkstra();
    REP(i,n){
        if(d[i]%2==0) cout<<0<<endl;
        else cout<<1<<endl;
    }
    return 0;
}

Measured memory_bytes: 32128
h,w=map(int, input().split())
c=[list(map(int, input().split())) for i in range(10)]
al=[list(map(int, input().split())) for i in range(h)]
ans=0
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
ans=0
for i in al:
    for j in i:
        if j==-1:continue
        ans+=c[j][1]
print(ans)

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

int main(){
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < 3; i++){
      if (S.at(i) == S.at(i+1)){
        count++;
      }
    }
  
  if (count > 0){
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>  
using namespace std;
int n,m,pri[1000],sinsa,ans[1000],fir;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
	cin>>pri[i];}
	for(int I=0;I<m;I++){
	cin>>sinsa;
	for(int II=0;II<n;II++){
		if(sinsa>=pri[II]){
		ans[II]++;II+=n;}}}
	for(int ii=0;ii<n;ii++){
		if(ans[fir]<ans[ii]){
		fir=ii;}}
	cout<<fir+1<<endl;
return 0;}


Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>

const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;

int len;
int dp[MAXN][13];
char s[MAXN];

int main() {
    scanf("%s", s + 1);
    len = strlen(s + 1);
    dp[0][0] = 1;
    for (int i = 1; i < 13; ++i) {
        dp[0][i] = 0;
    }
    for (int i = 0; i < len; ++i) {
        for (int j = 0; j < 13; ++j) {
            if (s[i + 1] != '?') {
                int tmp = s[i + 1] - '0';
                dp[i + 1][(j * 10 + tmp) % 13] += dp[i][j];
                if (dp[i + 1][(j * 10 + tmp) % 13] > mod)
                    dp[i + 1][(j * 10 + tmp) % 13] -= mod;
            }
            else {
                for (int k = 0; k <= 9; ++k) {
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                    if (dp[i + 1][(j * 10 + k) % 13] > mod)
                        dp[i + 1][(j * 10 + k) % 13] -= mod;
                }
            }
        }
    }
    printf("%d", dp[len][5]);
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,h,mi,i,a[101010],b[101010],hs;
int main()
{
	cin>>n>>h;
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		mi=max(mi,a[i]);
	}
	sort(b+1,b+1+n);
	for(i=n;i>=1;i--)
	{
		if(b[i]<mi)
			break;
		h-=b[i];
		hs++;
		if(h<=0)
		{
			cout<<hs<<"\n";
			return 0;
		}
	}
//	cout<<h<<" "<<mi<<"\n";
	hs+=ceil(double(h)/double(mi));
	cout<<hs<<"\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MOD(x) ((x)%mod)
long long n,m;
long long s1,s2,s3,s4,s5;
long long ans;
void cut2(int a,int b)
{
	s2=a/2*b;
	s3=(a-a/2)*b;
	s4=max(s1,s2);
	s4=max(s4,s3);
	s5=min(s1,s2);
	s5=min(s5,s3);
	ans=min(ans,s4-s5);
	s2=a*(b/2);
	s3=a*(b-b/2);
	s4=max(s1,s2);
	s4=max(s4,s3);
	s5=min(s1,s2);
	s5=min(s5,s3);
	ans=min(ans,s4-s5);
}
void cut3(int a,int b)
{
	if(a%3==0)
	{
		s1=a/3*b;
		cut2(a-a/3,b);
	}
	else
	{
		s1=a/3*b;
		cut2(a-a/3,b);
		s1=(a/3+1)*b;
		cut2(a-(a/3+1),b);
	}
	if(b%3==0)
	{
		s1=b/3*a;
		cut2(a,b-b/3);
	}
	else
	{
		s1=b/3*a;
		cut2(a,b-b/3);
		s1=(b/3+1)*a;
		cut2(a,b-(b/3+1));
	}
}
int main()
{
	ans=(long long)200000*(long long)200000;
	scanf("%lld%lld",&n,&m);
	cut3(n,m);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace _1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = 0;
            for (int i = 0; i < n; i++)
            {
                int x = int.Parse(Console.ReadLine());
                bool z = true;
                if (x == 2)
                {
                    z = true;
                }
                else if (x < 2 || x % 2 == 0)
                {
                    z = false;
                }
                else
                {
                    int j = 3;
                    while (j <= Math.Sqrt(x))
                    {
                        if (x % j == 0)
                        {
                            z = false;
                        }
                        j = j + 2;
                    }
                }
                if (z == true)
                {
                    a++;
                }
            }
            Console.WriteLine(a);
            Console.ReadLine();
        }
    }
}

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

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

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

  int ans = 0;

  // 単調非減少/非増加列を貪欲に伸ばしていく
  for (int i = 0; i < n; i++) {
    while (i + 1 < n && a[i] == a[i + 1]) i++;

    if (i + 1 < n && a[i] > a[i + 1]) {
      while (i + 1 < n && a[i] >= a[i + 1]) i++;
    } else if (i + 1 < n && a[i] < a[i + 1]) {
      while (i + 1 < n && a[i] <= a[i + 1]) i++;
    }

    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  long long t;
  long long A[n][m],B[m][l];

  //?????????+??\???
  for(int i = 0; i<n; i++){
    for(int k = 0; k<m; k++){
      A[i][k] = 0;
      cin >> A[i][k];
    }
  }
  for(int k = 0; k<m; k++){
    for(int j = 0; j<l; j++){
      B[k][j] = 0;
      cin >> B[k][j];
    }
  }

  //?????????
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){

      if(j!=l-1){
        for(int k=0; k<m; k++){
          t += A[i][k] * B[k][j];
          if(k == m-1){
            cout << t << " ";
            t = 0;
          }
        }
      }

      else{
        for(int k=0; k<m; k++){
          t += A[i][k] * B[k][j];
          if(k == m-1){
            cout << t << endl;
            t = 0;
          }
        }
      }
    }
  }

  return 0;
}

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

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    int L, R;
    string s;
    auto func = [](const string& str) -> int {
        if(str == "Vacant") exit(0);
        if(str == "Male")   return 0;
        else    return 1;
    };
    cout << 0 << '\n' << flush;
    cin >> s;
    L = func(s);
    cout << N - 1 << '\n' << flush;
    cin >> s;
    R = func(s);
    int lb = 0, ub = N - 1;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        int M;
        cout << mid << '\n' << flush;
        cin >> s;
        M = func(s);
        if((mid - lb) & 1){
            if(L == M){
                ub = mid;
                R = M;
            }
            else{
                lb = mid;
                L = M;
            }
        }
        else{
            if(L != M){
                ub = mid;
                R = M;
            }
            else{
                lb = mid;
                L = M;
            }
        }
    }
}

Measured memory_bytes: 3860
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

int main(){
    ll x; cin >> x;
    double n = 100;
    ll ans = 0;
    while(n < x){
        n *= 1.01;
        n = floor(n);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long ;
using namespace std;
const int nax = 1e9+5;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int>a(n), dp(n, nax);
    dp[0] = 0;
    for(int& i:a){scanf("%d", &i);}
    for(int i=0; i<n; i++){
        for(int j =i+1; j<=k+i; j++){
            if(j<n){
                dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
            }
        }
    }
    printf("%d", dp[n-1]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

ll gcd(ll x,ll y)
{
	if (x%y==0) return(y);
	else return(gcd(y,x%y));
}

int main(void){
    ll a,b,c,d,ans = 0,tmp,g,tmp2,ans2,ax;
    cin >> a >> b >> c >> d;
    ax = (a-1);
    ans += (b/c);
    ans += (b/d);
    ans -= (ax/c);
    ans -= (ax/d);
    g = gcd(c,d);
    tmp2 = c*d/g;
    ans -= (b/tmp2);
    ans += (ax/tmp2);
    ans2 = (b-a+1);
    ans2 -= ans;
    cout << ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    string = input()
    answer=""
    for s in string:
        if s.islower()==True:
            answer+=s.upper()
        elif s.isupper():
            answer+=s.lower()
        else:
            answer+=s
    print(answer)

if __name__=="__main__":
    main()


Measured memory_bytes: 5564
def comb(n,r,mod):
	'''
	return nCr
	O(min{n-r, r})
	'''
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod


mod = 10**9+7

N,a,b = map(int,input().split())

ans = pow(2, N, mod) -1
ans -= comb(N,a,mod)
if ans<0:
    ans += mod
ans -= comb(N,b,mod)
if ans<0:
    ans += mod

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    string S, T;
    cin >> S >> T;
    
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<char>());
    
    if (S < T) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>

void update(int a,int b);

using namespace std;

const double EPS = 1e-10;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};
const int INF = 1001001001;

#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))
#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

pair<int, int> seg[1 << 18];



int main(){
  int n,r,l;
  int team[100000]={0};
  
  scanf("%d %d %d",&n,&r,&l);
  for(int i=0; i<n; i++) update(i,0);
  int watch=0,sento=0;

  for (int i=0;i<r;i++){
    int g,y,z;
    scanf("%d %d %d",&g,&y,&z);
    team[sento]+=y-watch;
    update(g-1,z);
    sento=seg[0].second-1;
    watch=y;
  }
  team[sento]+=l-watch;
  
  int maxi = 0;
  for (int i=1;i<n;i++){
    if(team[maxi]<team[i]) maxi=i;
  }
  printf("%d\n",maxi+1);
  return (0);
}



void update(int k, int x)
{
	int id = k + 1;
	k += (1 << 17) - 1;
	seg[k].first += x;
	seg[k].second = id;
	while (k){
		k = (k - 1) / 2;
		if (seg[k * 2 + 1].first > seg[k * 2 + 2].first){
			seg[k] = seg[k * 2 + 1];
		}
		else if (seg[k * 2 + 1].first < seg[k * 2 + 2].first){
			seg[k] = seg[k * 2 + 2];
		}
		else {
			seg[k] = seg[k * 2 + 1];
		}
	}
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////



int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < LEN(s); i++) {
		int val = s[i]-'A';
		val = (val+n)%26;
		s[i] = val+'A';
	}
	cout << s << '\n';

	return 0;
}


Measured memory_bytes: 3620
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0/*,-1,0*/ }, dy[4] = { 0,1/*,0,-1*/ };
/**************/

typedef long double ld;
typedef unsigned long long ull;
const int MX = 3007;

ld f[MX][MX], p[MX];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	f[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			f[i + 1][j + 1] += f[i][j] * p[i];
			f[i + 1][j] += f[i][j]*(1.0-p[i]);
		}
	}
	ld ans = 0.0;
	for (int i = 0; i <= n; i++) {
		if (n<= i*2 ) {
			ans += f[n][i];
		}
	}
	
	cout << fixed <<setprecision(20)<< ans << endl;
	//printf("%22.20lf", ans);
	return 0;
}



Measured memory_bytes: 141568
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	int n = 0;
	cin >> n;
	while(n--){
		int x = 0, y = 0, w = 0, h = 0;
		cin >> x >> y >> w >> h;
		int catnum = 0;
		cin >> catnum;
		int count = 0;
		for(int i = 0; i < catnum; i++){
			pair<int, int> tmp;
			cin >> tmp.first >> tmp.second;
			if((tmp.first>=x&&tmp.first<=x+w)&&(tmp.second>=y&&tmp.second<=y+h)) count++;
		}
		cout << count << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long cd, ab;
        double result;

        for(int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        Arrays.sort(a);
        result = (double)(a[n - 1] + a[n - 2]) / (double)(a[1] - a[0]);
        for(int i = 1; i < n - 1; i++) {
            if(i + 1 == n - 1) {
                cd = a[n - 1] - a[n - 2];
                ab = a[n - 3] + a[n - 4];
            } else if(i + 1 == n - 2) {
                cd = a[n - 2] - a[n - 3];
                ab = a[n - 1] + a[n - 4];
            } else {
                cd = a[i + 1] - a[i];
                ab = a[n - 1] + a[n - 2];
            }
            result = Math.max(result, (double)ab / (double)cd);
        }
        System.out.printf("%.6f\n", result);
        }
}

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

int main(){
  int N;
  cin >> N;
  if(N < 1200){
    cout << "ABC" << endl;
  } else if(N < 2800) { 
    cout << "ARC" << endl;
  } else { 
    cout << "AGC" << endl;
  }
}

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

//const lol mod=1e9+7;

/*  author: H3XoRuSH  */

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol d,n;
    cin >> d >> n;
    if(n==100) n++;
    lol ans=pow(100,d)*n;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

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

int main(void){
  ll i,N,X,x;
  cin >> N >> X;
  vector<ll> d_x(N);
  REP(i,N){
    cin >> x;
    d_x[i] = abs(X-x);
  }
  ll D  = d_x[N-1];
  REP(i,N-1){
    D = gcd(d_x[i],D);
  }
  cout << D << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,Q;
	cin>>n>>Q;
	vector<pair<int,string>> v(n+1);
	v[0]=pair<int,string>(0,"kogakubu10gokan");
	rep(i,n){
		cin>>v[i+1].F>>v[i+1].S;
	}
	auto it=upper_bound(ALL(v),pair<int,string>(Q,"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"));
	it--;
	cout<< it->S <<endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

Measured memory_bytes: 1212
#include <stdio.h>

int main(void)
{
	int sx,sy,tx,ty;
	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
	tx=tx-sx;
	ty=ty-sy;
	sx=0;
	sy=0;
	int i;
	
	for(i=0;i<tx;i++){
		printf("R");
	}
	for(i=0;i<ty;i++){
		printf("U");
	}
	for(i=0;i<tx;i++){
		printf("L");
	}
	for(i=0;i<ty;i++){
		printf("D");
	}
	printf("L");
	for(i=0;i<ty+1;i++){
		printf("U");
	}
	for(i=0;i<tx+1;i++){
		printf("R");
	}
	printf("D");
	printf("R");
	for(i=0;i<ty+1;i++){
		printf("D");
	}
	for(i=0;i<tx+1;i++){
		printf("L");
	}
	printf("U\n");
	return 0;
}

Measured memory_bytes: 128
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n, x = map(int, input().split())
x_list = list(map(int, input().split()))
move = []
for i in range(n):
    a = abs(x - x_list[i])
    move.append(a)
print(gcd_list(move))

Measured memory_bytes: 16308
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

#define N 100030


ll d[100010];



//----------------------------------------------------------------
signed main(){
   
    int n,m;
	cin >> n >> m;
	rep(i,n)d[i] = INF;
	d[0] = 0;
	
	vector<pair<pair<int,ll>,int>> p(m);//s,c,t
	rep(i,m){
		int s,t,c;
		cin >> s >> t >> c;
		p[i] = MP(MP(s-1,c),t-1);
	}
	SORT(p);

	rep(i,m){
		int s = p[i].fi.fi;
		int t = p[i].se;
		int c = p[i].fi.se;
		int res = d[s]+c;
		for(int j = t;j>=s;j--){
			if(res >= d[j])break;
			d[j] = res;
		}
	}

	if(d[n-1] == INF)cout << -1 << endl;
	else cout << d[n-1] << endl; 

	rep(i,n)cerr << d[i] << endl;
  
	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc144.contest.atcoder.jp/tasks/abc144_b


Measured memory_bytes: 3328
// https://atcoder.jp/contests/agc037/tasks/agc037_a
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

string s;
int len;
int memo[200005];
int rec(int start, string before) {
    if (start >= len) {
        return 0;
    }
    if (memo[start] != 0) {
        return memo[start];
    }

    int sai = 0;
    for (int i = 1; i <= 2; i++) {
        string t = s.substr(start, i);
        if (t != before) {
            int ret = rec(start + i, t) + 1;
            if (sai < ret) {
                sai = ret;
            }
        }
    }
    return memo[start] = sai;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    len = s.length();
    cout << rec(0, "") << endl;

    return 0;
}


Measured memory_bytes: 34324
#include<stdio.h>
int main(){
  unsigned int n,i,a,b=1,c=0;
  scanf("%d",&n);
  c=n;
  while(n--){
    scanf("%d",&a);//printf("%d\n",a);
    for(i=1;i*i<a;i++){
      if(a%(i*2+1)-i)continue;
      c--;//printf(":%d\n",i);
      break;
    }
  }
  printf("%d\n",c);
  return 0;
}

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

int main() {
    int n, k;
    string s;
    int score = 0;
    
    cin >> n >> k >> s;
    
    for (int i = 0; i < (n - 1); i++) {
        if (s[i] == s[i + 1]) {
            score++;
        }
    }
    
    cout << min(score + 2 * k, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long, long>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

template< typename T = long >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< 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);
}

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	double _max = -1;
	int sato_water = -1, sato = -1;

	rep2 (a, 0, 31) rep2 (b, 0, 31) rep2 (c, 0, 3001) {
		if (!a && !b) continue;
		int water = 100 * A * a + 100 * B * b;
		if (water + C * c > F) break;
		int ok = min(E * A * a + E * B * b - C * c, F - water - C * c);
		if (ok < 0) break;
		int Dd = ok / D * D;
		if (chmax(_max, (double)(C * c + Dd)/(water + C * c + Dd))) {
			sato_water = water + C * c + Dd;
			sato = C * c + Dd;
		}
	}

	cout << sato_water << " " << sato << endl;
	return 0; 
}

Measured memory_bytes: 3584
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <string>

//typedef pair<int,int> P;

using namespace std;

const int INF=INT_MAX/3;
const int N=1000;

int heap[N];
string output;

void parse(string &s,int id){

  //cout<<s<<":"<<id<<endl;
  if(s.empty()) return;

  heap[id]++;
  if(s=="(,)") return;
  if(id>=N) return;
  
  int cnt=0;
 
  for(int i=1;i<s.length()-1;i++){
    if(s[i]=='(') cnt++;
    if(s[i]==')') cnt--;  
    if(s[i]==',' && cnt==0){
      string sub1=s.substr(1,i-1);
      string sub2=s.substr(i+1,s.length()-i-2);
      if(i-1>=0) parse(sub1, 2*id+1);
      if(s.length()-i-2>=0)parse(sub2, 2*id+2);
      break;
    }
  }
  return;
}

void out(int th, int id){

  output.push_back('(');

  int ch1=0,ch2=0;//n of string of each child
  
  if(heap[id]>th && heap[2*id+1]>th){
    out(th,2*id+1);
  }
  output.push_back(',');
  if(heap[id]>th && heap[2*id+2]>th){
    out(th,2*id+2);
  }
  
  output.push_back(')');
  return;
  
}

void print(){

  for(int i=0;i<N;i++)
    cout<<"["<<i<<"]"<<heap[i]<<endl;
}

void solve(string cmd,string &s1,string &s2){

  fill(heap,heap+N,0);
  output.clear();
  //cout<<output<<endl;
  parse(s1,0);
  parse(s2,0);


  int th=-1;
  if(cmd=="u") th=0;
  if(cmd=="i") th=1;
  out(th,0);
  
  cout<<output<<endl;
}



int main(){

  string cmd,s1,s2;
  int i=0;
  
  while(cin>>cmd>>s1>>s2){
    solve(cmd,s1,s2);
  }

  return 0;
}

Measured memory_bytes: 3184