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

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  
  for (int i = 1; i <= B; i++) {
    if (A * i % B == C) {
      printf("YES");
      return 0;
    }
  }

  printf("NO");
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n; cin>>n; cin.ignore();
    vi x(n);
    int avgnum=0, avgdenom=n;
    for (int i = 0; i<n; ++i) {
        cin>>x[i];
        avgnum += x[i];
    }

    int cand1, cand2, cand3;

    cand2 = avgnum/avgdenom;
    cand1 = cand2-1;
    cand3 = cand2+1;

    int d1=0, d2=0, d3=0;
    for (int i = 0; i<n; ++i) {
        d1 += (cand1-x[i])*(cand1-x[i]);
        d2 += (cand2-x[i])*(cand2-x[i]);
        d3 += (cand3-x[i])*(cand3-x[i]);
    }
    cout<<min({d1,d2,d3})<<el;

}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

struct D {
    int node;
    int step;
    this(int node, int step) {
        this.node = node;
        this.step = step;
    }
}

int calc(int n, int s, int t, int[][] adj) {
    auto q = new Queue!(D);
    q.push(D(s, 0));
    auto used = new int[][](n + 1, 3); // [ノード数][mod 3]
    while (!q.empty) {
        auto d = q.pop();
        if (used[d.node][d.step % 3]++) continue;
        if (d.node == t && d.step % 3 == 0) return d.step / 3;

        foreach (e; adj[d.node]) {
            q.push(D(e, d.step + 1));
        }
    }
    return -1;
}

void main() {
    int n, m; scan(n, m);

    int[][] adj;
    for (int i = 0; i <= n; i++) adj ~= [[]];

    for (int i = 0; i < m; i++) {
        int u, v; scan(u, v);
        adj[u] ~= v;
    }

    int s, t; scan(s, t);
    writeln(calc(n, s, t, adj));
}

class Queue(T) {
    private DList!(T) _dlist;
    private ulong _size;

    this(T[] ary) {
        _dlist = DList!(T)(ary);
        _size = ary.length;
    }

    this() {
        _dlist = DList!(T)();
        _size = 0;
    }

    void push(T x) {
        _dlist.insertBack(x);
        _size++;
    }

    T pop() {
        T x = _dlist.front;
        _dlist.removeFront();
        _size--;
        return x;
    }

    @property T front() {
        return _dlist.front;
    }

    @property ulong size() {
        return _size;
    }

    @property bool empty() {
        return _dlist.empty;
    }
}


Measured memory_bytes: 13436
#include <stdio.h>
#include <stdlib.h>
int main(){
  int K,A,B,i,count;
  count=0;
  scanf("%d",&K);
  scanf("%d %d",&A,&B);
  for(i=A;i<B+1;i++){
    if(i%K==0) count=1;
  }
  if(count==1) printf("OK");
  else printf("NG");
  return 0;
}

Measured memory_bytes: 1728
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	d = Dict{Int,Int}()
	ans = 0
	for i in 1:n
		if haskey(d,i-a[i])
			ans+=d[i-a[i]]
		end
		if haskey(d,a[i]+i)
			d[a[i]+i]+=1
		else
			d[a[i]+i]=1
		end
	end
	println(ans)
end

main()

Measured memory_bytes: 199476
/**********************************************
 *Author*        :coderdz
 *Created Time*  : 2018/6/6 13:18:58

*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep(i, n) for(int i = 1; i <= n; i++)
#define m(a, b) memset(a, b, sizeof(a))
typedef pair<int, int> PII;
typedef long long ll;
const int MAXN = 3e5 + 10;
int l[MAXN], r[MAXN];
inline void OPEN(string s){
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main(){
    IO;
	int n, num_w = 0, num_e = 0;
	string s;
	cin >> n >> s;
	int len = s.size();
	for(int i = 0; i < len; i++){
		if (s[i] == 'W') num_w++;
		else num_e++;
	}
	if (s[0] == 'W') l[0] = 0, r[0] = num_e;
	else l[0] = 0, r[0] = num_e - 1;
	for(int i = 1; i < len; i++){
		if (s[i-1] == 'W'){
			l[i] = l[i-1] + 1;
			if (s[i] == 'E') r[i] = max(0, r[i-1] - 1);
			else r[i] = max(r[i-1], 0);
		}
		else{
			l[i] = l[i-1];
			if (s[i] == 'E') r[i] = max(r[i-1] - 1, 0);
			else r[i] = max(0, r[i-1]);
		}
	}
    int ans = 1<<30;
    for(int i = 0; i < len; i++)
    	ans=min(ans, r[i] + l[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2964
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# PyPyだと再帰が遅いので注意
# BEGIN CUT HERE
sys.setrecursionlimit(100000)
class UnionFind():
    '''UnionFind木'''
    def __init__(self,n):
        self.data = [-1] * n
    
    def unite(self, x, y):
        '''x と y を結合'''
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        elif self.data[x] < self.data[y]:
            x, y = y, x  # swap
        self.data[x] += self.data[y]
        self.data[y] = x
    
    def root(self, x):
        '''ノード x の親を返す'''
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]

    def same(self, x, y):
        '''x と y が同じグループに属するか判定'''
        return self.root(x) == self.root(y)
    
    def size(self, x):
        '''x を含むグループのノード数を返す'''
        return self.data[self.root(x)]
        
# END CUT HERE

def ABC120_D():
    n, m = mi()
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = mi()
        
    uf = UnionFind(n)
    ans = [0] * (m + 1)
    ans[m] = n * (n - 1) // 2

    for i in range(m - 1, -1, -1):
        a[i] -= 1
        b[i] -= 1
        ans[i] = ans[i + 1]
        if uf.same(a[i], b[i]):
            continue
        
        x = uf.size(a[i])
        y = uf.size(b[i])
        ans[i] -= x * y
        
        uf.unite(a[i],b[i])
    
    for i in range(1, m + 1):
        print(ans[i])

# verified on 2019/06/23
# Python3:616ms https://atcoder.jp/contests/abc120/submissions/6094323

def ABC126_E():
    N, M = mi()
    uf = UnionFind(N)
    for i in range(M):
        _X, _Y, _Z = mi()
        uf.unite(_X - 1, _Y - 1)
    ans = 0
    for i in range(N):
        if uf.root(i) == i:
            ans += 1
    print(ans)
# verified on 2019/06/23
# Python3:468ms https://atcoder.jp/contests/abc126/submissions/6094497

def ABC131_F():
    from collections import defaultdict
    MAX = 100010
    uf = UnionFind(2 * MAX)
    N = ii()
    for i in range(N):
        x, y = mi()
        uf.unite(x, y + MAX)
    
    mx = defaultdict(int)
    for i in range(MAX):
        mx[uf.root(i)] += 1
    my = defaultdict(int)
    for i in range(MAX,2*MAX):
        my[uf.root(i)] += 1
    ans = 0
    for i in range(2 * MAX):
        ans += mx[i] * my[i]
    print(ans - N)


if __name__ == '__main__':
    # ABC120_D()
    # ABC126_E()
    ABC131_F()

Measured memory_bytes: 47724
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,k;
  cin >> n >> k;
  
  vector<int> ck(n);
  
  REP(i,n){
    int b;
    cin >> b;
    ck[b-1]++;
  }
  
  sort(ck.begin(),ck.end(), greater<int>());
  
  int cnt = k;
  int sum = 0;
  
  REP(i,n){
    if(k == 0) break;
    k--;
    sum += ck[i];
  }
  
  cout << n-sum << endl;
    

              
}

Measured memory_bytes: 4068
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vvi = vector<vector<int>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	string s; cin >> s;
	if (s[0] == s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static void Main(string[] args)
        {
            int N = ReadInt();
            Console.WriteLine(Enumerable.Range(1, N).Select(i => (long)i).Where(i => i % 3 != 0 && i % 5 != 0).Sum());
        }
    }
}


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

int main(){
    int n, k;
    cin >> n;
    vector<char>s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    cin >> k;
    char con = s.at(k - 1);
    //cout << con << endl;
    for (int i = 0; i < n; i++) {
        if (s.at(i) != con) {
            s.at(i) = '*';
        }
    }
    for (int i = 0; i < n; i++) {
        cout << s.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long int n;
 cin>>n;
 map<long long int,long long int>mp;
 for(int i=2;i<=n;i++){
 	int x;
 	cin>>x;
 	mp[x]++;
  }
  for(int i=1;i<=n;i++){
  	cout<<mp[i]<<"\n";
  }
}

Measured memory_bytes: 16132
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
 
        System.out.println((n-w+1) * (n-h+1));
    }
}

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

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    ll N,M;
    cin >> N >>M;
    vector<pair<int,int>> edge;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >>b;
        --a;--b;
        edge.emplace_back(a,b);
    }
    ll ans =0;
    for(int i=0;i<M;i++){
        UnionFind uf = UnionFind(N);
        for(int j=0;j<M;j++){
            if(i==j){
                continue;
            }
            uf.unite(edge[j].first,edge[j].second);
        }
        for(int j=0;j<N;j++){
            if(!uf.same(0,j)){
                ans++;
                break;
            }
        }

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

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;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

const ll mod = 1e9 + 7 ;

int main()
{
    ios;
    ll n , m ;
    cin >> n >> m ;
    ll ans;
    ll tot = n + m ;
    ll nn = n , mm = m ;
    forn(i , 1 , tot) {
       if(i == 1){
        ans = n ;
        ans = ans % mod ;
        --n ;
        con ;
       }
       else {
        if(i % 2 == 1){
            if(n <= 0 ) n = 0 ;
            ans = ans * n ;
            --n ;

        ans = ans % mod ;
            con ;
        }
        else {
            if(m <= 0) m = 0 ;
            ans = ans * m ;
            --m ;

        ans = ans % mod ;
            con ;
        }
       }
    }

        ans = ans % mod ;
    ll cnt = ans ;
    ans = 0 ;
    n = nn ;
    m = mm ;
    forn(i , 1 , tot){
       if(i == 1){
         ans = m ;
         --m ;

        ans = ans % mod ;
         con ;
       }
       else {
        if(i % 2 == 1){
            if(m <= 0) m = 0 ;
            ans = ans * m ;

        ans = ans % mod ;
            --m ;
            con ;
        }
        else {
            if(n <= 0 ) n = 0 ;
            ans = ans * n ;
            --n ;

        ans = ans % mod ;
            con ;
        }
       }
    }

        ans = ans % mod ;
    cnt = cnt + ans ;
    cnt = cnt % mod ;
    cout << cnt << el ;
    ro ;
}































Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  tmp = int(input())
  tmp_list = []
  for j in range(tmp):
    xy = list(map(int, input().split()))
    tmp_list.append(xy)
  A.append(tmp_list)
ans = 0
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f
for bit in range(2**N):
  flag = True
  for i in range(N):
    if bit >> i & 1:
      for j in range(len(A[i])):
        if (A[i][j][1]^(bit >> (A[i][j][0]-1)&1)):
          flag = False
          break
    else:
      continue
    if not flag:
      break
  if flag:
    ans = max(ans, popcount(bit))
print(ans)

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

int main(){
    long long int N;
    cin >> N;
    long long int count = 0;

    long long int EXN = N;

    vector<long long int> prime_count(2,0);

    long long int counter;

    for(long long int i = 2; i*i <= EXN;i++){

        int x = 0;

        while(N%i == 0){
            N = N/i;
            x++;
        }

        if(x != 0){
            prime_count.push_back(x);
        }
    }

    for(long long int i = 2; i < prime_count.size(); i++){
        counter = 1;
        while(prime_count.at(i) - counter >= 0){
            count ++;
            prime_count.at(i) -= counter;
            counter ++;
        }
    }

    if(N != 1){
        count ++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 2010
using namespace std;
int l[N][N],r[N][N],f[N][N];
bool mp[N][N];
char str[N];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++) mp[i][j]=str[j]=='#';
	}
	int ans=max(n,m);
	n--;m--;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			mp[i][j]=mp[i][j]^mp[i][j+1]^mp[i+1][j]^mp[i+1][j+1];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		if(!mp[i][j]) l[i][j]=l[i][j-1]+1;
		for(int j=m;j>=1;j--)
		if(!mp[i][j]) r[i][j]=r[i][j+1]+1;
	}
	for(int i=1;i<=m;i++) l[0][i]=r[0][i]=100000000;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(mp[i][j])
			{
				f[i][j]=0;
				l[i][j]=r[i][j]=100000000;
			}
			else
			{
				f[i][j]=f[i-1][j]+1;
				l[i][j]=min(l[i][j],l[i-1][j]);
				r[i][j]=min(r[i][j],r[i-1][j]);
				ans=max(ans,(f[i][j]+1)*(l[i][j]+r[i][j]));
			}
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 51456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_061
{
    class A
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] abc = Console.ReadLine().Split(' ');
            a = int.Parse(abc[0]);
            b = int.Parse(abc[1]);
            c = int.Parse(abc[2]);

            if(c >= a && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main()
{
    int t;
    cin >> t;
    string str;
    cin >> str;
    if(t%2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    string ans = "Yes";
    for(int i = 0; i < t / 2; ++i)
    {
        if(str[i] != str[i+t/2])
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n,t,a;
    cin>>n>>t>>a;
    t*=1000;
    a*=1000;
    int mn=1e9;
    int ans=0;
    for (int i=0;i<n;i++) {
        int h;
        cin>>h;
        int b=abs(t-6*h-a);
        if (b<mn) {
            mn=b;
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
print("R"*(tx-sx)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"+"D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(ty-sy))

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A;
    cin >> A;
    int B;
    cin >> B;
    int C;
    cin >> C;

    if(A==B) cout << C << endl;
    else if(C==B) cout << A << endl;
    else if(C==A) cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

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

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 1000000007
	n,m = readline() |> split |> parseMap
	a = Array{Int}(m)
	for i in 1:m
		a[i] = readline() |> parseInt
	end
	push!(a,n+1)
	now = shift!(a)
	dp = zeros(Int,n+1)
	dp[1] = 1
	if now==1
		dp[2] = 0
		now = shift!(a)
	else
		dp[2] = 1
	end
	for i in 3:n+1
		if i-1 == now
			dp[i] = 0
			now = shift!(a)
		else
			dp[i] = (dp[i-1]+dp[i-2])%mod
		end
	end
	println(dp[n+1])
end

main()

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

static const int N=100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }

  for(int i=1;i<=n;i++) m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1<<21);
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  cout<<m[1][n]<<endl;

  return 0;
}



Measured memory_bytes: 3136
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    int t;
    cin>>t;
    int ac=0,wa=0,tle=0,re=0;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        ac++;
        if(s=="WA")
        wa++;
        if(s=="TLE")
        tle++;
        if(s=="RE")
        re++;
        
        
    }
    
    cout<<"AC"<<" "<<"x"<<" "<<ac<<"\n";
cout<<"WA"<<" "<<"x"<<" "<<wa<<"\n";
cout<<"TLE"<<" "<<"x"<<" "<<tle<<"\n";
cout<<"RE"<<" "<<"x"<<" "<<re<<"\n";
    
    

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
typedef long long ll;

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

using namespace std;

int main(){
    ll r, d, a;

    cin >> r >> d >> a;

    for(int i = 0; i < 10; i++){
        ll b = a * r - d;
        cout << b << endl;
        a = b;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))

l = 10**6 + 10
B = [0] * l
for i in range(2, l):
    if B[i] == 0:
        j = 0
        while i*j < l:
            if B[i*j] == 0:
                B[i*j] = i
            j += 1

pc_ng = 0
D = [0] * l
for i in range(n):
    C = []
    a = A[i]
    while a != 1:
        C.append(B[a])
        a //= B[a]
    # print(C)
    C = list(set(C))
    for j in range(len(C)):
        if D[C[j]] == 1:
            pc_ng = 1
            break
        else:
            D[C[j]] = 1

if pc_ng == 0:
    print("pairwise coprime")
    sys.exit()

g = A[0]
from math import gcd
for i in range(1, n):
    g = gcd(g, A[i])
# print(g)

if g == 1:
    print("setwise coprime")
else:
    print("not coprime")
        

Measured memory_bytes: 182784
#include <iostream>

using namespace std;

int main(void)
{
  long N, M;
  int p[100000];
  string S[100000];

  int progress[100000];

  for (long i = 0; i < N; i++) {
    progress[i] = 0;
  }

  long correct = 0, penalty = 0;

  cin >> N >> M;
  for (long i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }

  for (long i = 0; i < M; i++) {
    if (S[i] == "AC" && progress[p[i]] != -1) {
      penalty += progress[p[i]];
      correct++;
      progress[p[i]] = -1;
    } else if (S[i] == "WA" && progress[p[i]] != -1) {
      progress[p[i]]++;
    }
  }

  cout << correct;
  cout << " ";
  cout << penalty;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc144/abc144_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

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

  bool ok = a <= 9 && b <= 9;

  cout << (ok ? a * b : -1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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 chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




signed main(void)
{
    ll n;
    cin >> n;
    ll a;
    ll r = 0;
    ll c = 0;
    
    rep(i, n) {
        cin >> a;
        if (a != c+1) {
            r++;
        } else {
            c++;
        }
    }
    if (c == 0) {
        mes(-1);
        re0;
    }
    mes(r);
}

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

int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if((r<=x)&&(x<=W-r)&&(r<=y)&&(y<=H-r)) cout << "Yes" << endl;
    
    else cout << "No" << endl;
}


Measured memory_bytes: 3116
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	int n, l,sum=0;
	int rig = 0;
	cin >> n >> l;
	vector<pi> ringo;
	REP(i, n) {
		rig = i + l - 1;
		ringo.push_back(make_pair(abs(rig), rig));
		sum += rig;
	}
	sort(all(ringo));
	pi ring = *ringo.begin();
	int badrig = ring.second;
	cout << sum - badrig << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAXN 200010
long long A[MAXN << 2], B[MAXN << 2], T[MAXN << 2];
inline void pushDown(int x) {
	if (!T[x])return;
	A[x << 1] += T[x]; A[x << 1 | 1] += T[x];
	B[x << 1] += T[x]; B[x << 1 | 1] += T[x];
	T[x << 1] += T[x]; T[x << 1 | 1] += T[x];
	T[x] = 0;
}
inline void pushUp(int x) {
	A[x] = std::min(A[x << 1], A[x << 1 | 1]);
	B[x] = std::min(B[x << 1], B[x << 1 | 1]);
}
void Insert(int n, int l, int r, int x, long long v) {
	if (l == r) {
		A[n] = std::min(A[n], v - x); B[n] = std::min(B[n], v + x); return;
	}
	pushDown(n); int mid = (l + r) >> 1;
	if (x <= mid)Insert(n << 1, l, mid, x, v);
	else Insert(n << 1 | 1, mid + 1, r, x, v);
	pushUp(n);
}
void Insert(int n, int l, int r, int L, int R, long long v) {
	if (l == L && r == R) {
		A[n] += v; B[n] += v; T[n] += v; return;
	}
	pushDown(n); int mid = (l + r) >> 1;
	if (R <= mid)Insert(n << 1, l, mid, L, R, v);
	else if (L > mid)Insert(n << 1 | 1, mid + 1, r, L, R, v);
	else Insert(n << 1, l, mid, L, mid, v), Insert(n << 1 | 1, mid + 1, r, mid + 1, R, v);
	pushUp(n);
}
long long a(int n, int l, int r, int L, int R) {
	if (l == L && r == R)return A[n];
	pushDown(n); int mid = (l + r) >> 1;
	if (R <= mid)return a(n << 1, l, mid, L, R);
	else if (L > mid)return a(n << 1 | 1, mid + 1, r, L, R);
	return std::min(a(n << 1, l, mid, L, mid), a(n << 1 | 1, mid + 1, r, mid + 1, R));
}
long long b(int n, int l, int r, int L, int R) {
	if (l == L && r == R)return B[n];
	pushDown(n); int mid = (l + r) >> 1;
	if (R <= mid)return b(n << 1, l, mid, L, R);
	else if (L > mid)return b(n << 1 | 1, mid + 1, r, L, R);
	return std::min(b(n << 1, l, mid, L, mid), b(n << 1 | 1, mid + 1, r, mid + 1, R));
}
int n, q, p[MAXN], x;
int main() {
	scanf("%d%d%d", &n, &q, &x);
	for (int i = 0; i <= q; i++)scanf("%d", &p[i]);
	memset(A, 0x3F, sizeof(A)); memset(B, 0x3F, sizeof(B));
	Insert(1, 1, n, x, 0);
	for (int i = 1; i <= q; i++) {
		long long now = std::min(a(1, 1, n, 1, p[i]) + p[i], b(1, 1, n, p[i], n) - p[i]);
		Insert(1, 1, n, 1, n, std::abs(p[i] - p[i - 1]));
		Insert(1, 1, n, p[i - 1], now);
	}
	long long ans = 0x7FFFFFFFFFFFFFFF;
	for (int i = 1; i <= n; i++) {
		ans = std::min(ans, a(1, 1, n, i, i) + i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19712
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		short[] abc = {sc.nextShort(),sc.nextShort(),sc.nextShort()};
		short tmp;
		for(byte i = 0;i < abc.length;i++){
			for(byte j = -1;j < abc.length - 1;j++){
				if(abc[i] < abc[j + 1]){
					tmp = abc[j+1];
					abc[j+1] = abc[i];
					abc[i] = tmp;
				}
			}
		}
		System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
	}
}


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

using namespace std;
using namespace std::chrono; 

#define ull unsigned long long int
#define ll long long int 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")



int solve(){

    int bingo[3][3];

    for(int i=0; i<3; i++){
        cin >> bingo[i][0] >>  bingo[i][1] >>  bingo[i][2];
    }
    int n;
    int x;
    cin >> n;

    for(int i=0; i<n; i++){

        cin >> x;

        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(bingo[j][k] == x) bingo[j][k] = -1;
            }
        }

    }

    for(int j=0; j<3; j++){
        for(int k=0; k<3; k++){
            if((bingo[j][k] == -1 && (bingo[j][k] == bingo[j][k-1]) && (bingo[j][k]== bingo[j][k+1]))  && (k-1 >=0 && k+1 <3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j+1][k] && bingo[j][k] == bingo[j-1][k]) && (j+1<3 && j-1>=0)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k-1] && bingo[j][k] == bingo[j+1][k+1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k+1] && bingo[j][k] == bingo[j+1][k-1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    time__("programm time"){
		int t = solve();
	}
    return 0;

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, x, t = map(int, input().split())
    res = (n + x - 1) // x * t
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9156
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

#define TEST 0
#if TEST
FILE *in = freopen("./question.txt", "r", stdin);
FILE *out = freopen("./answer.txt", "w", stdout);
#endif

int dx[4] = { 0, 1, 0, -1 }; //????????????
int dy[4] = { 1, 0, -1, 0 };
int w, h;
int min_count;
int data[20][20];

bool check_range(int nx, int ny){
	if (nx >= 0 && nx < w && ny >= 0 && ny < h){
		return true;
	}
	return false;
}

int dfs(int x, int y, int count){
	int OK=-1;
	if(count > 9)return OK;
	for (int i = 0; i < 4; i++){
		int nx=x;
		int ny=y;
		for (int j = 0; j < 20; j++){
			nx += dx[i];
			ny += dy[i];
			if(data[y+dy[i]][x+dx[i]]==1)break;
			if (!check_range(nx, ny)){
				break;
			}
			// cout << "ny " << ny << " nx " << nx << " data " << data[ny][nx] << endl;
			if (data[ny][nx] == 3){
				if (min_count > count + 1) min_count = count + 1;
				return min_count;
			}
			if (data[ny][nx] == 1){
				data[ny][nx] = 0;
				nx -= dx[i];
				ny -= dy[i];
				// cout <<"ny " << ny << " nx " << nx << endl;
				OK = dfs(nx, ny, count + 1);
				data[ny+dy[i]][nx+dx[i]] = 1;
				break;
			}
		}
	}
	if(min_count<11) return min_count;
	else return OK;
}

int main(void){
	while (1){
		min_count = 11;
		cin >> w >> h;
		if (!w && !h) break;

		int s_x, s_y;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> data[i][j];
				if (data[i][j] == 2){
					s_x = j;
					s_y = i;
				}
			}
		}

		int count = 0;
		int cnt = dfs(s_x, s_y,count);
		cout << cnt << endl;

	}
	#if TEST
	fclose(in);
	fclose(out);
	#endif
	return 0;
}

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

def f(N, K):
    b = min(K.bit_length(), N)
    return 2**b + (N-b)*K


def test():
    assert f(4,3) == 10
    assert f(10,10) == 76


def main():
    N = int(input())
    K = int(input())
    print(f(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
typedef long long int llint;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>x(n, -1);
	vector<int>y(n, -1);
	vector<int>h(n, -1);
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int tmp = -1;
	for (int Y = 0;Y < 101;Y++) {
		for (int X = 0;X < 101;X++) {
			for (int i = 0;i < n;i++) {
				if (h[i] > 0) {
					if (tmp == -1) {
						tmp = h[i] + abs(X - x[i]) + abs(Y - y[i]);
					}
					else {
						if (tmp != h[i] + abs(X - x[i]) + abs(Y - y[i])) {
							tmp = -1;
							break;
						}
					}
				}
			}
			if (tmp == -1) {
				continue;
			}
			for (int i = 0;i < n;i++) {
				if (h[i] == 0) {
					if (tmp > h[i] + abs(X - x[i]) + abs(Y - y[i])) {
						tmp = -1;
						break;
					}
				}
			}
			if (tmp == -1) {
				continue;
			}
			cout << X << " " << Y << " " << tmp << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
 
using namespace std;
 
int main()
{
      string s;
      cin>>s;
      ll i,sum=0;
      ll n = s.size();
      for(i=0;i<n;i++)
      {
              ll x = s[i]-48;
              sum+=x;
      }
      if(sum%9==0)
       {
               cout<<"Yes"<<endl;
       }       
       else
       {
              cout<<"No"<<endl;
       }
  
  
    return 0; 
}


Measured memory_bytes: 3732
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
		Array.Sort(input);

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

			Console.WriteLine("{0} {1} {2}" ,a ,b ,c);

    }
}


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

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 998244353;

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

int main() {
	ll n, m, k;
	cin >> n >> m >> k;

	ll cn_1[k + 1];
	ll cur = 1;
	for(ll i = 0; i <= k; i++) {
		cn_1[i] = cur;
		cur = cur * (n - 1 - i) % mod;
		cur = cur * modinv(i + 1, mod) % mod;
	}
	ll ans = 0;

	ll ms1[n + 1];
	cur = 1;
	for(ll i = 0; i <= n; i++) {
		ms1[i] = cur;
		cur = (cur * (m - 1)) % mod;
	}

	rep(i , k + 1) {
		//cout << "i:" << i << " cn_1:" << cn_1[i] << " ms[n - k]:" << ms[n - i] << " m1[n - i - 1]:" << ms1[n - i - 1] << endl; 
		ll a = (((cn_1[i] * m) % mod) *  ms1[n - i - 1]) % mod;
		//cout << a << endl;
		ans = (ans + a) % mod;
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 6228
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>
#include<random>
#include<thread>

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/rope>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pair<int,int>>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-10;
const ll mod=1e9+7;

int a[555][555];

int main(){
    CPPinput;
    int n,m; cin>>n>>m;
    for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)cin>>a[i][j];
    vector<pii> vv;
    vector<pair<pii,pii>> v;
    for(int i=1;i<=n;++i){
        if(i&1){
            for(int j=1;j<=m;++j){
                vv.eb(i,j);
            }
        }
        else{
            for(int j=m;j>=1;--j){
                vv.eb(i,j);
            }
        }
    }
    for(int i=1;i<vv.size();++i){
        if(a[vv[i-1].first][vv[i-1].second]%2){
            v.eb(vv[i-1],vv[i]);
            ++a[vv[i].X][vv[i].Y];
        }
    }
    cout<<v.size()<<endl;
    for(auto p:v){
        cout<<p.first.first<<" "<<p.first.second<<" "<<p.Y.X<<" "<<p.Y.Y<<endl;
    }
}


Measured memory_bytes: 7280
def main():
    l, r = map(int, input().split())
    rng = r - l
    ans = float("inf")
    if rng >= 2018:
        ans = 0
    else:
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, (i * j) % 2019)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import math
import time
t1 = time.time()
N = int(input())
answer = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        x = math.gcd(i, j)
        for k in range(j+1, N+1):
            answer += 6*math.gcd(x, k)
for i in range(1, N+1):
    for j in range(1, N+1):
        if i != j:
            answer += 3*math.gcd(i, j)
        else:
            answer += math.gcd(i, j)
print(answer)

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

int main()
{
    string UNRESTORABLE = "UNRESTORABLE";

    string s, t; cin >> s >> t;

    if(s.size() < t.size())
    {
        cout << UNRESTORABLE << endl;
        return 0;
    }

    set<string> st;

    int sn = s.size(), tn = t.size();

    for(int off = 0; off <= sn - tn; off++)
    {
        int fl = 1;

        for(int i = 0, j = off; i < tn; i++, j++) if(s[j] != '?')
            fl &= s[j] == t[i];

        if(!fl) continue;

        auto tmp = s;

        for(int i = 0, j = off; i < tn; i++, j++) if(tmp[j] == '?')
            tmp[j] = t[i];

        for(auto& c : tmp) if(c == '?') c = 'a';

        st.insert(tmp);
    }

    if(st.empty())
    {
        cout << UNRESTORABLE << endl;
        return 0;
    }

    cout << *begin(st) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        var set = new HashSet<long> { N };
        if (N > 2) { set.Add(N - 1); }
        for (long i = 2; i * i <= N - 1; ++i)
        {
            if ((N - 1) % i == 0)
            {
                set.Add(i);
                if (i * i < N - 1) { set.Add((N - 1) / i); }
            }
        }
        for(long i = 2; i * i <= N; ++i)
        {
            long n = N;
            while (n % i == 0) { n /= i; }
            if (n % i == 1) { set.Add(i); }
        }
        Console.WriteLine(set.Count);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define no {puts("No");return 0;}
#define yes {puts("Yes");return 0;}
#define nc() getchar()
using namespace std;
const int N=300010;

/*inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
inline int read(){
    char ch=nc();int sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
 
int c[N],n;

void add(int x,int k){
	while(x<=n){
		c[x]+=k;
		x+=x&-x;
	}
}

int query(int x){
	int ans=0;
	while(x){
		ans+=c[x];
		x-=x&-x;
	}
	return ans;
}

int a[N],fu[N],s[N];
bool vis[N];

int main(){
	n=read();
	int s1=0,s2=0;
	for(int i=1;i<=3;i++){
		for(int j=1;j<=n;j++){
			int x;
			x=read();
			if(i==1){
				if(x%3==0){
					a[j]=x/3;
					
					fu[j]=1;
					if(j&1) s1++;
					
					else s2++;
				}else{
					if(x%3!=1) {no;}
					a[j]=x/3+1;
				}
				if(vis[a[j]]) {no;}
				if((j&1)^(a[j]&1)) {no;}
				vis[a[j]]=1;
			}
			else{
				if(fu[j]){
					if(x!=a[j]*3-i+1) {no;}
				}else{
			//		printf("a(%d)=%d\n",j,a[j]);
					if(x!=(a[j]-1)*3+i) {no;}
				}
			}
		}
	}
//	for(int i=1;i<=n;i++) printf("%d ",a[i]);cout<<endl;
	
	int i;
	
	if(n&1) i=n;else i=n-1;
	
	for(;i>0;i-=2){
		s2+=query(a[i]);
		add(a[i],1);
	}
	
	if(n&1) i=n-1;else i=n;
	
	memset(c,0,sizeof(c));
	
	for(;i>0;i-=2){
		s1+=query(a[i]);
		add(a[i],1);
	}
	
	
//	printf("%d %d\n",s1,s2);
	
	if(s1%2==0&&s2%2==0) {yes;}
	else {no;}
	
	return 1;
}
			
	

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int a,b;
    char c;
    cin >> a >> c >> b;
    if( c == '+' )
        cout << a + b << endl;
    else
        cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
pp = []
for _ in range(M):
  a, b = map(int, input().split())
  cc = map(int, input().split())
  bit = 0
  for c in cc:
    bit += 1 << (c - 1)
  pp.append((a, bit))

inf = 10000000

S = 1 << N
dp = [inf] * S
dp[0] = 0
for s in range(1, S):
  for a, bit in pp:
    dp[s] = min(dp[s], a + dp[s - (s & bit)])
if dp[S-1] >= inf:
  print(-1)
else:
  print(dp[S-1])

Measured memory_bytes: 45400
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b;
  cin >> a >> b;
  long long g = __gcd(a, b);
  map<long long, long long> res;
  for(long long i = 2; i*i < g; i++){
    while(g%i == 0){
      res[i]++;
      g /= i;
    }
  }
  if(g != 1) res[g] = 1;
  cout << res.size()+1 << endl;
  return 0;
}

Measured memory_bytes: 256